User Tools

Site Tools


Tips on Quaternions

Since 1.5, Foundation allows to mod Custom component and links it to a fbx (see Exemple02)

Assuming the local axis Y of the building is vertical (most cases), a way to compute the cosinus (named cosp) and sinus (named sinp) of the rotation angle of the building around the vertical is the following:

        local q = self:getOwner():getGlobalOrientation()
        local sinp = 2 * q[4] * q[2]
        local cosp = q[4] * q[4] - q[2] * q[2]


1) You can check that cosp*cosp + sinp*sinp is near 1

2) This can be used, for instance, to convert a local direction on XZ plane (local coordonates for “translate”), to a global direction (global coordonates for “rayCast”).

guides/tips-on-quaternion.txt · Last modified: 2021/02/23 11:57 by minotorious