PyGLM
PyGLM copied to clipboard
How to use 'rotate' with quaternion
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?
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 (:
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?