Math wizardry

Richard Miller wow at together.net
Mon Mar 28 16:40:45 EST 2005


Well James.. I think that does it!  Very much appreciated.

Richard



On Mar 28, 2005, at 2:02 PM, Jim MacConnell wrote:

> Richard,
>
>> All of these give different values for the resulting angles, depending
>> on the direction from which the lines are drawn. How do I consistently
>> determine the angle between the two lines?
>
> I think you may want to take a different approach. Since the user is 
> drawing
> the lines, it sounds like you actually know the "coordinates" of three
> points, (Call them A, B and C). That means you know everything you 
> need to
> know to define all the angles.
>
> The function you need to use is the "Law of Cosines"....
> a^2 = b^2 + c^2 - 2bc(cos(A))
>
> So draw a triangle and label accordingly...
> PointA is the intersection point,
> PointB is the one of the "non-intersection" points
> PointC is the ... Yes the other.
>
> LineAB is a line from PointA to PointB (called "c" in the "Law" 
> because it
> is "across: from the angle at PointC)
> LineAC is a line from PointA to PointC (the "b" from the "Law")
> LineBC is a line from PointB to PointC (the "a" from the "Law")
>
> xA,yA are the coordinates of PointA (the intersection)
> xB,yB are the coordinates of PointB
> xC,yC are the coordinates of PointC
>
> LengthAB is the length of a line from A to B (LineAB):
> ( i.e. LengthAB = sqrt ( (xA - xB)^2 + (yA - yB )^2))
>
> LengthAC is the length of a line from A to C (LineAC)
> ( i.e. LengthAC = sqrt ( (xA - xC)^2 + (yA - yC )^2))
>
> lengthBC is the length of a line from B to C (LineBC)
> ( i.e. LengthBC = sqrt ( (xB - xC)^2 + (yB - yC )^2))
>
> The angle between the 2 lines (the angle between  LineAB and LineAC is
> obtained by rearranging the "Law" and subtituting our teminalogy.:
>
> Angle= acos( (lengthAB^2 + lengthAC^2 - lengthBC^2)/ (2 * lengthAB *
> lengthAC) )
>
> --watch the parentheses...... And check for my typos?
>
> The advantage here is that there are no signs to deal with... The only 
> thing
> that matters is the length between points.
>
> Now if you want to know the angles of the two lines in real space, 
> calculate
> the angle of LineAB (or another) and use addition to get the others.
>
> Hope this helps,
> Jim
>
>
>
> -- 
> James H. MacConnell
>
> Consensus Technology, LLC
> Seattle, WA
> www.consensustech.com
>
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list