Math wizardry
Jim Hurley
jhurley at infostations.com
Mon Mar 28 13:34:21 EST 2005
Richard,
I should have said that the funciton "theLineAngle" below assumes you
define the line *either* by the two end points p1, and p2
Or
by the line as defined in Run Rev, that is "the points of grc
"myLine". The "points" consists of the point p1 followed by a return
character and then point p2.
So that you can say:
put theLineAngle(the points of grc "myLine") into tAngleOne.
Jim
function theLineAngle p1,p2
--Angle of line defined by the two points p1 and p2
get the paramcount
if it is 1 then
put line 2 of p1 into p2
put line 1 of p1 into p1
end if
put item 1 of p2 - item 1 of p1 into dx
put item 2 of p2 - item 2 of p1 into dy
put atan2(dy,dx) into tAngle
return (tAngle)
end theLineAngle
The function theAngleBetween will always return an angle "a" such that 0<a<pi/2
I think this is the number you want. If not, let me know.
(If you want degrees, multiply all angle in radians by 180/pi.)
Jim
More information about the use-livecode
mailing list