Date: Wed, 7 Aug 1996 14:18:30 -0700 From: "Glenn M. Picher" <gpicher@maine.com> Subject: Re: ** MATHS Question ** >How do you do inverse sine, tan and cosine functions using Lingo?I think this is all correct, but there might be a faster solution. Inverse tan:
atan()Already built into Lingo.
on asin ratio
return atan(ratio/sqrt(1.0 - (ratio * ratio)))
end
If ratio is less than or equal to -1.0, or greater than or
equial to 1.0, then you get a divide by zero error. But
that wouldn't be a valid triangle anyway, so an angle
measurement would be meaningless.
on acos ratio
return atan(sqrt(1.0 - (ratio * ratio))/ratio)
end
If ratio is 0.0, you get a divide by zero error. But that
wouldn't be a valid triangle, either.
on degrees theRadians return theRadians * 57.2957795786 end on radians theDegrees return theDegrees / 57.2957795786 endThus, as you would expect...
put degrees(asin(sin(radians(30.0)))) -- 30.0 put acos(cos(1.0)) -- 1.0
>Given a right-angled triangle and the lengths of each side, how do I >find out the size of the other two angles?
on topAngle base, height return atan(base/height) end on sideAngle base, height return atan(height/base) endJust be sure you don't pass in 0 length base or height values, or you'll get a divide by zero error.
The answer is returned in radians.
It you need to calculate both angles, it would be faster to calculate one angle and then derive the other angle by subtracting from 90 degrees. Transcendental math functions are rather slow.