Math wizardry
Roger.E.Eller at sealedair.com
Roger.E.Eller at sealedair.com
Sat Oct 15 15:16:07 EDT 2005
On Tue, 29 Mar 2005 05:13:44 -0800, Jim Hurley wrote to Jim MaConnell:
>
> Jim,
> Perhaps even easier would be to define a function which determines
> the *geometrical* angle associated with a line in Run Rev. Any
> geometrical line rotated 180 degrees is the same geometrical line.
> Therefore the function below eliminates the signs associated with
> Run Rev angle.
>
>
> function theGeometrialAngle p1,p2
> --Geometrical 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
> --Add or subtract pi as needed.
> switch
> case tAngle < 0
> return tAngle + pi
> break
> case tAngle > pi
> return tAngle - pi
> break
> default
> return tAngle
> end switch
> end theGeometrialAngle
>
> function tAngleBetween a1,a2
> return abs(a1 - a2)
> end tAngleBetween
> And so the geometrical angle between two Run Rev lines is just the
absolute value of the difference.
>
>
> Jim
Hello Jim(s),
I was trying to use this function with a real-world problem and it isn't
giving me the result (an angle between 1 and 360) that I expected. I have
an image object (a scan of some text). The image wasn't scanned straight,
so I thought I would draw a grc line in parallel with the text in the
scan. I am trying to use the functions above to determine the angle of the
grc line object so that I can rotate the image to make it straight. The
function always returns a number that is less than 3. Can someone explain
why this is or offer another way to determine the angle of a line? Math is
NOT my strength.
TIA,
Roger Eller <roger.e.eller at sealedair.com>
More information about the use-livecode
mailing list