PyGLM icon indicating copy to clipboard operation
PyGLM copied to clipboard

How to use 'rotate' with quaternion

Open shorttrack789 opened this issue 1 year ago • 2 comments

        m_model = glm.mat4()
        # translate
        m_model = glm.translate(m_model, self.transf.position.getvec3())
        # rotate
        m_model = glm.rotate(m_model, self.transf.rotation.z, glm.vec3(0, 0, 1))
        m_model = glm.rotate(m_model, self.transf.rotation.y, glm.vec3(0, 1, 0))
        m_model = glm.rotate(m_model, self.transf.rotation.x, glm.vec3(1, 0, 0))
        # scale
        m_model = glm.scale(m_model, (self.transf.scale.x, self.transf.scale.y, self.transf.scale.z))
        return m_model

How to use rotate method with quaternion?

shorttrack789 avatar Aug 26 '23 04:08 shorttrack789

Here's a page that might help you understand how to use Quaternions for rotation: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/

Basically, you create a quaternion from an axis and angle (e.g. using glm.angleAxis) and you apply the rotation by multiplying the quaternion and your point.

If you need further details, feel free to ask (:

Zuzu-Typ avatar Aug 26 '23 06:08 Zuzu-Typ

Here's a page that might help you understand how to use Quaternions for rotation: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/

Basically, you create a quaternion from an axis and angle (e.g. using glm.angleAxis) and you apply the rotation by multiplying the quaternion and your point.

If you need further details, feel free to ask (:

Isn’t there any ways not to use Euler angles?

shorttrack789 avatar Aug 26 '23 09:08 shorttrack789