MCPcopy Create free account
hub / github.com/defold/defold / QuatToEuler

Function QuatToEuler

engine/script/src/script_vmath.cpp:2660–2668  ·  view source on GitHub ↗

converts a quaternion into euler angles * * Converts a quaternion into euler angles (r0, r1, r2), based on YZX rotation order. * To handle gimbal lock (singularity at r1 ~ +/- 90 degrees), the cut off is at r0 = +/- 88.85 degrees, which snaps to +/- 90. * The provided quaternion is expected to be normalized. * The error is guaranteed to be less than +/- 0.02 degrees *

Source from the content-addressed store, hash-verified

2658 * ```
2659 */
2660 static int QuatToEuler(lua_State* L)
2661 {
2662 Quat* q = CheckQuat(L, 1);
2663 Vector3 euler = dmVMath::QuatToEuler(q->getX(), q->getY(), q->getZ(), q->getW());
2664 lua_pushnumber(L, euler.getX());
2665 lua_pushnumber(L, euler.getY());
2666 lua_pushnumber(L, euler.getZ());
2667 return 3;
2668 }
2669
2670 /*# converts euler angles into a quaternion
2671 *

Callers 6

UpdateRotationToEulerFunction · 0.50
TEST_FFunction · 0.50
TYPED_TESTFunction · 0.50
SetNodePropertyFunction · 0.50
LuaSetRotationFunction · 0.50
TEST_FFunction · 0.50

Calls 6

CheckQuatFunction · 0.85
lua_pushnumberFunction · 0.85
getXMethod · 0.45
getYMethod · 0.45
getZMethod · 0.45
getWMethod · 0.45

Tested by 3

TEST_FFunction · 0.40
TYPED_TESTFunction · 0.40
TEST_FFunction · 0.40