Community Forum

getRotation of steerables

Forum Overview >> Scripting

CategoryScripting
Created01.11.2010 09:56


Andreas Großschedl (Unknown) 01.11.2010 10:00
Hi!

I need to get the Rotation of steerables so i did that:

rx,ry,rz=getRotation(g_currentMission.steerables[1].rootNode);

i need the ry value, but this is only 0 to 90 deg and 0 to -90 deg but i need 0 to 360 deg. Do i need a second value to compare?

Thx
Andi

Markus Uphoff (Unknown) 01.11.2010 10:21
you want to know the rotation of the vehicle you drive at the moment?

local x,y,z = localDirectionToWorld(self.rootNode, 0, 0, 1);
local length = Utils.vector2Length(x,z);
local dX = x/length
local dZ = z/length
local TDirection = math.deg(math.atan2(dX,dZ))
if TDirection < 0 then
TDirection = 360 - (TDirection * -1)
end

TDirection is the direction in degree (0-360)

i hope i can help



Andreas Großschedl (Unknown) 01.11.2010 20:37
yes, this works fine. Maybe you can tell me what you are doing here?

thanks

Markus Uphoff (Unknown) 02.11.2010 17:35
what i´m doing here?
help other users and get help

Andreas Großschedl (Unknown) 03.11.2010 07:07
Yes, of course! But that's not what i meant. I wanted to know what the base of this calculation is, because i maybe need such a thing a few times?

thx

Stefan Geiger - GIANTS Software 15.11.2010 09:25
The code calculates the angle of the object's z-axis about the world y-axis.

You should make yourself familiar with the atan2 function, this is the main part in the code above.

localDirectionToWorld(self.rootNode, 0, 0, 1) simply returns the vector of the object's z-axis.



Andreas Großschedl (Unknown) 15.11.2010 14:39
Thank you for the explanation!


Note: Log in to post. Create a new account here.