| 135 | |
| 136 | |
| 137 | int LuaVector::length(lua_State* L) { |
| 138 | const int count = lua_gettop(L); |
| 139 | float sum = 0.0f; |
| 140 | for (int i = 1; i <= count; i++) { |
| 141 | const float v = luaL_checkfloat(L, i); |
| 142 | sum += v * v; |
| 143 | } |
| 144 | lua_checkstack(L, 1); |
| 145 | lua_pushfloat(L, sqrtf(sum)); |
| 146 | return 1; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | int LuaVector::normalize(lua_State* L) { |
no test coverage detected