Sign in to follow this  
Alessandro

Guessing and finding point coordinates (with screenshot)

Recommended Posts

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

[img]http://www.alessandromastronardi.com/downloads/math1.jpg[/img]

Share this post


Link to post
Share on other sites
You can use [url="http://mathworld.wolfram.com/BarycentricCoordinates.html"]barycentric coordinates[/url] 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 this post


Link to post
Share on other sites
[quote name='apatriarca' timestamp='1311269512' post='4838537']
You can use [url="http://mathworld.wolfram.com/BarycentricCoordinates.html"]barycentric coordinates[/url] 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]
[/quote]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this