ShiVa3D
Convert object direction (rotation) to yaw and pitch
Paste down any little snippets or request a new one.Convert object direction (rotation) to yaw and pitch
by neilb » 01 May 2011, 02:08
Shiva's got some functions to specify rotations as yaw, pitch and roll, but there's nothing I could find to get an object's rotation as yaw and pitch.
The following will convert the vector returned by object.getDirection() to yaw and pitch.
The following will convert the vector returned by object.getDirection() to yaw and pitch.
- Code: Select all
local dx, dy, dz = object.getDirection(application.getCurrentUserActiveCamera, object.kGlobalSpace)
local yaw = -math.atan2(dx, -dz)
local pitch = math.atan2(dy, math.sqrt((dx * dx) + (dz * dz)))
2 posts
• Page 1 of 1

