converts euler angles into a quaternion * * Converts euler angles (x, y, z) in degrees into a quaternion * The error is guaranteed to be less than 0.001. * If the first argument is vector3, its values are used as x, y, z angles. * * @name vmath.euler_to_quat * @param x [type:number|vector3] rotation around x-axis in degrees or vector3 with euler angles in degrees
| 2689 | * ``` |
| 2690 | */ |
| 2691 | static int EulerToQuat(lua_State* L) |
| 2692 | { |
| 2693 | if (lua_type(L, 1) == LUA_TNUMBER) |
| 2694 | { |
| 2695 | float x = (float) luaL_checknumber(L, 1); |
| 2696 | float y = (float) luaL_checknumber(L, 2); |
| 2697 | float z = (float) luaL_checknumber(L, 3); |
| 2698 | PushQuat(L, dmVMath::EulerToQuat(dmVMath::Vector3(x, y, z))); |
| 2699 | return 1; |
| 2700 | } |
| 2701 | |
| 2702 | Vector3* v = CheckVector3(L, 1); |
| 2703 | PushQuat(L, dmVMath::EulerToQuat(*v)); |
| 2704 | return 1; |
| 2705 | } |
| 2706 | |
| 2707 | static const luaL_reg methods[] = |
| 2708 | { |