MAtan does what it says it does
by Gary "ChunkyKs" Briggs · in Torque Game Builder · 03/26/2005 (12:25 am) · 3 replies
From mConsoleFunctions.cc:
And returning "the slope in radians (the arc-tangent) of a line with the given rise and run" is exactly what it does.
Unfortunately, T2D uses degrees to do stuff like %object.setRotation. So my code now looks like this:
Go go gadget magic numbers.
Is it possible for T2D functions such as this one to return angles in degrees?
Gary (-;
ConsoleFunction( mAtan, F32, 3, 3,
"(float rise, float run) Returns the slope in radians"
"(the arc-tangent) of a line with the given rise and run.")
{
return(mAtan(dAtof(argv[1]), dAtof(argv[2])));
}And returning "the slope in radians (the arc-tangent) of a line with the given rise and run" is exactly what it does.
Unfortunately, T2D uses degrees to do stuff like %object.setRotation. So my code now looks like this:
%theta = 57 * mAtan(%a.ry[%i] - %a.ry[%i+1], %a.rx[%i] - %a.rx[%i+1]); // mAtan returns radians
Go go gadget magic numbers.
Is it possible for T2D functions such as this one to return angles in degrees?
Gary (-;
#2
But in the meantime, T2D uses the system of "0 degrees is vertical, and wind clockwise". So I'd expect all the helper functions to follow that.
Gary (-;
03/26/2005 (2:29 am)
Yes, yes I can.But in the meantime, T2D uses the system of "0 degrees is vertical, and wind clockwise". So I'd expect all the helper functions to follow that.
Gary (-;
#3
You can use...
Hope this helps,
- Melv.
03/26/2005 (3:11 am)
Bugs forum? ;)You can use...
%theta = mRadToDeg( mAtan(%a.rx[%i+1] - %a.rx[%i], %a.ry[%i] - %a.ry[%i+1]) );... or instead of using...
%x = cos(%theta) %y = -sin(%theta)... you can use...
%x = sin(%theta) %y = -cos(%theta)
Hope this helps,
- Melv.
Torque Owner Teck Lee Tan