Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

WhatEver

R3 rotation arround an arbitrary axis...

This topic is 6380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to do this. I read the Dian Grubber artical but I don''t undertsnad those formulas, much less implimenting it in OpenGL. I want to use the method so I can start using bones in my models.

Share this post


Link to post
Share on other sites
Advertisement
First you need to know how to multiply matrices, or at least know how to do it in openGL. But assuming that you already know how to do that, here is how you rotate around an arbitrary axis given by a vector

(note: this assumes the vector has a length of one)

angle = the amout of rotation (usually in radians)
v = vector that is rotated around
c = cos(angle);
s = sin(angle);
matrix[0][0] = (v.x * v.x) * (1.0f - c) + c
matrix[0][1] = (v.y * v.x) * (1.0f - c) + (v.z * s)
matrix[0][2] = (v.z * v.x) * (1.0f - c) - (v.y * s)
matrix[0][3] = 0
matrix[1][0] = (v.x * v.y) * (1.0f - c) - (v.z * s)
matrix[1][1] = (v.y * v.y) * (1.0f - c) + c
matrix[1][2] = (v.z * v.y) * (1.0f - c) + (v.x * s)
matrix[1][3] = 0
matrix[2][0] = (v.x * v.z) * (1.0f - c) + (v.y * s)
matrix[2][1] = (v.y * v.z) * (1.0f - c) - (v.x * s)
matrix[2][2] = (v.z * v.z) * (1.0f - c) + c
matrix[2][3] = 0
matrix[3][0] = 0
matrix[3][1] = 0
matrix[3][2] = 0
matrix[3][3] = 1

then you multiply the vertices by this matrix and poof you''ve just rotated an object around an arbitrary axis.
There might be an easyer way to do it in opengl but i dont know enough to help you there.
hope that helps

Share this post


Link to post
Share on other sites
Wow, I''ll give it a try in OpenGL. Thank you =D

Does anyone here know how to push this into the OpenGL matrix?

Do all matrices get multiplied by each other, even the Transformation matrix?

I''m learning .

Share this post


Link to post
Share on other sites
Nevermind...

This seem easy enough

void glMultMatrixf(
const GLfloat *m
);

I''m gonna have some fun with this...oh yeah...bones here I come!!!!!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!