# Guessing and finding point coordinates (with screenshot)

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, given a triangle with known P1,P2,P3 coordinates, I'd like to be able to guess n points that lie inside of it, and their coordinates. See attached image for a better explanation.
Thanks

##### Share on other sites
What do you mean by guess? Do you want to generate n random points inside the triangle? Do you want a uniform distribution?

##### Share on other sites
Not a uniform distribution: just say you want to guess 100 points in sparse order which lie inside the triangle...

##### Share on other sites
You can use barycentric coordinates like in the following pseudocode:

[source]a = rand(0,1)
b = rand(0,1 - a)
c = 1 - a - b
P = a*P1 + b*P2 + c*P3[/source]

EDIT: Corrected a typo

##### Share on other sites

You can use barycentric coordinates like in the following pseudocode:

[source]a = rand(0,1)
b = rand(0,1 - a)
c = 1 - a - c
P = a*P1 + b*P2 + c*P3[/source]

Thank you very much, I'm going to try this !

• 23
• 10
• 19
• 15
• 14