Vec2:rotate documentation

@sim The vec2:rotate() uses angles in radians. This is correctly indicated in the reference documentation, but the inline ‘hint’ when typing in the command says degrees-needs to be corrected.

That is actually a bug, it looks like the help is for the incorrect function (the global rotate function) rather than the method. Thank you for the report!

ahhh!

I notice also that vec3:rotate() seems to work, although not documented. It seems to rotate about the z axis only.

Hah, you are correct, just checked the C-bindings and here is the commented code for vec3’s rotate:

/////////////////////////////////////////////////////////////////////////////////////////////////
//THESE ONLY ROTATE IN 2D — For compatibility with people using vec2 returned from mesh.vertices!
static int Lrotate(lua_State *L)
{
    lua_Number *o1 = checkvec3up(L, 1, 1);
    
    if( o1 )
    {
        lua_Number a = luaL_checknumber(L, 2);
        
        lua_Number *r = Pnew(L);
        r[0] = MATHF(cos)(a)*o1[0] - MATHF(sin)(a)*o1[1];
        r[1] = MATHF(sin)(a)*o1[0] + MATHF(cos)(a)*o1[1];
        r[2] = o1[2];
        return 1;        
    }
    
    return 0;
}
1 Like