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

Function Quat_new

engine/script/src/script_vmath.cpp:1198–1218  ·  view source on GitHub ↗

creates a new quaternion from its coordinates * * Creates a new quaternion with the components set * according to the supplied parameter values. * * @name vmath.quat * @param x [type:number] x coordinate * @param y [type:number] y coordinate * @param z [type:number] z coordinate * @param w [type:number] w coordinate * @return q [type:quaternion] ne

Source from the content-addressed store, hash-verified

1196 * ```
1197 */
1198 static int Quat_new(lua_State* L)
1199 {
1200 Quat q;
1201 if (lua_gettop(L) == 0)
1202 {
1203 q = Quat::identity();
1204 }
1205 else if (lua_gettop(L) == 1)
1206 {
1207 q = *CheckQuat(L, -1);
1208 }
1209 else
1210 {
1211 q.setX((float) luaL_checknumber(L, 1));
1212 q.setY((float) luaL_checknumber(L, 2));
1213 q.setZ((float) luaL_checknumber(L, 3));
1214 q.setW((float) luaL_checknumber(L, 4));
1215 }
1216 PushQuat(L, q);
1217 return 1;
1218 }
1219
1220 /*# creates a quaternion to rotate between two unit vectors
1221 *

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.85
identityFunction · 0.85
CheckQuatFunction · 0.85
luaL_checknumberFunction · 0.85
PushQuatFunction · 0.85
setZMethod · 0.80
setWMethod · 0.80
setXMethod · 0.45
setYMethod · 0.45

Tested by

no test coverage detected