projects a vector onto another vector * * Calculates the extent the projection of the first vector onto the second. * The returned value is a scalar p defined as: * * p = |P| cos θ / |Q| * * where θ is the angle between the vectors P and Q. * * @name vmath.project * @param v1 [type:vector3] vector to be projected on the s
| 2332 | * ``` |
| 2333 | */ |
| 2334 | static int Project(lua_State* L) |
| 2335 | { |
| 2336 | Vector3* v1 = CheckVector3(L, 1); |
| 2337 | Vector3* v2 = CheckVector3(L, 2); |
| 2338 | float sq_len = dmVMath::LengthSqr(*v2); |
| 2339 | if (sq_len == 0.0f) |
| 2340 | return luaL_error(L, "The second %s.%s to %s.%s must have a length bigger than 0.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_VECTOR3, SCRIPT_LIB_NAME, "project"); |
| 2341 | lua_pushnumber(L, dmVMath::Dot(*v1, *v2) / sq_len); |
| 2342 | return 1; |
| 2343 | } |
| 2344 | |
| 2345 | /*# performs an element wise multiplication of two vectors |
| 2346 | * |
nothing calls this directly
no test coverage detected