Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use 'rotate' with quaternion #217

Open
shorttrack789 opened this issue Aug 26, 2023 · 2 comments
Open

How to use 'rotate' with quaternion #217

shorttrack789 opened this issue Aug 26, 2023 · 2 comments

Comments

@shorttrack789
Copy link

        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?

@Zuzu-Typ
Copy link
Owner

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 (:

@shorttrack789
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants