Math Help?
Scott Rossi
scott at tactilemedia.com
Fri Apr 30 17:28:22 EDT 2010
Many thanks Malte and Jeff. I now have a couple of good options to work
with. I knew there must be some way to test this.
(I could not rely on Rev's built-in within()/intersection functions in this
case because I need to translate this behavior to another environment.)
Thanks & Regards,
Scott Rossi
Creative Director
Tactile Media, UX Design
Recently, Malte Pfaff-Brill wrote:
> function withinTriangle x1,y1,x2,y2,x3,y3,px,py
> -- x1 / y1 to x3 / y3 define the triangle, pX and pY are the point to check
> local area1,area2
> put area(x1,y1,x2,y2,px,py) + area(x2,y2,x3,y3,px,py) +
> area(x3,y3,x1,y1,px,py) into area1
> put area(x1,y1,x2,y2,x3,y3) into area2
> return abs(area1-area2)<0.000000000001
> end withinTriangle
>
> function area x1,y1,x2,y2,x3,y3
> return abs(x1*y2+x2*y3+x3*y1-x1*y3-x3*y2-x2*y1)/2
> end area
More information about the use-livecode
mailing list