Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Guessing and finding point coordinates (with screenshot)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 Alessandro   Members   

302
Like
0Likes
Like

Posted 21 July 2011 - 10:33 AM

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

Posted Image

#2 apatriarca   Members   

2354
Like
0Likes
Like

Posted 21 July 2011 - 11:12 AM

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

#3 Alessandro   Members   

302
Like
0Likes
Like

Posted 21 July 2011 - 11:23 AM

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

#4 apatriarca   Members   

2354
Like
1Likes
Like

Posted 21 July 2011 - 11:31 AM

You can use barycentric coordinates like in the following pseudocode:

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


EDIT: Corrected a typo



#5 Alessandro   Members   

302
Like
0Likes
Like

Posted 21 July 2011 - 12:47 PM

You can use barycentric coordinates like in the following pseudocode:

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


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




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.