mAtan giving error message even when it works
by Luis E Pabon · in iTorque 2D · 10/03/2011 (2:25 pm) · 3 replies
In the API, it states that mAtan has one parameter: %val. It also works perfectly if used like that. However, the console spams error messages when doing it like that. I tried switching to mAtan(%rise, %sun), but that function was not working as I expected.
Example:
Running this code gives me the following message:
The value in %angle is correct though.
If I switch comments in the code, I don't get a message but the value of %angle is incorrect.
Example:
%val = %normal.X / %normal.Y;
%angle = mAtan(%val);
//%angle = mAtan(%normal.X, %normal.Y);
echo("%angle" SPC %angle);Running this code gives me the following message:
scripts/player.cs (52): ::mAtan - wrong number of arguments. scripts/player.cs (52): usage: ( val ) Use the mAtan function to get the inverse tangent of rise/run in radians. @param rise Vertical component of a line. @param run Horizontal component of a line. @return Returns the slope in radians (the arc-tangent) of a line with the given rise and run. @sa mTan
The value in %angle is correct though.
If I switch comments in the code, I don't get a message but the value of %angle is incorrect.
About the author
#2
By using:
I get the value I needed (I was using the wrong equation).
What I gather from this is that both input types are valid, but %val gives an error message due to an oversight.
10/03/2011 (4:57 pm)
I fixed my equation to "Y / X", but it still displays the error message.By using:
%angle = 1 / mAtan(%normal.Y, %normal.X);
I get the value I needed (I was using the wrong equation).
What I gather from this is that both input types are valid, but %val gives an error message due to an oversight.
#3
10/05/2011 (12:48 am)
I use mAtan all the time, for converting analog joystick values into angles like this:%targetAngle = mRadToDeg(mAtan(getWord(%aimVector, 1), getWord(%aimVector, 0))) + 90;
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
(if its single value its normally x / y, but if its two its normally y,x and that it mentions rise first, I would expect it to be the case here too)