Skip to main content
added 606 characters in body
Source Link

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

EDIT What I want is to rotate object on Y-axis using quaternion. So far,because of lack of my understanding, I m failing to rotate. I created a class 3dVector ->three dimensional vector, and instantiate a new position (0,0,-5). This position I sent as translate matrix to opengl and multiplied with glPosition.

When I tried to rotate that object using quaternion. I just took that position (0,0,-5) and used it in formula q = q * p * q(conjugate). I manually calculated that but result I get didnt make object rotate on Y-axis around itself. Now I m not sure, but I think it actually rotated object but not around him self,he was moved to the right, so he was not in the same position anymore

EDIT_2:

I have cube that is on position [0,0,-5] and I want to rotate it around y-axis by some angle.

I tried to write code in python

poinToRotate = Quaternion(w=0,x=0,y=0,z=-5) angle =45 sinus = math.sin(math.radians(angle)); q=Quaternion( w=math.cos(math.radians(angle)), x=sinus*0, y=sinus*1, z=sinus*) newPoint = q.rotate(poinToRotate) 

Rotation is somewhere good but it cube does not rotate around it self but around some point. But when

 p = Quaternion(w=0,x=0,y=0,z=0) 

to make it to the center, result is all zeros.

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

EDIT What I want is to rotate object on Y-axis using quaternion. So far,because of lack of my understanding, I m failing to rotate. I created a class 3dVector ->three dimensional vector, and instantiate a new position (0,0,-5). This position I sent as translate matrix to opengl and multiplied with glPosition.

When I tried to rotate that object using quaternion. I just took that position (0,0,-5) and used it in formula q = q * p * q(conjugate). I manually calculated that but result I get didnt make object rotate on Y-axis around itself. Now I m not sure, but I think it actually rotated object but not around him self,he was moved to the right, so he was not in the same position anymore

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

EDIT What I want is to rotate object on Y-axis using quaternion. So far,because of lack of my understanding, I m failing to rotate. I created a class 3dVector ->three dimensional vector, and instantiate a new position (0,0,-5). This position I sent as translate matrix to opengl and multiplied with glPosition.

When I tried to rotate that object using quaternion. I just took that position (0,0,-5) and used it in formula q = q * p * q(conjugate). I manually calculated that but result I get didnt make object rotate on Y-axis around itself. Now I m not sure, but I think it actually rotated object but not around him self,he was moved to the right, so he was not in the same position anymore

EDIT_2:

I have cube that is on position [0,0,-5] and I want to rotate it around y-axis by some angle.

I tried to write code in python

poinToRotate = Quaternion(w=0,x=0,y=0,z=-5) angle =45 sinus = math.sin(math.radians(angle)); q=Quaternion( w=math.cos(math.radians(angle)), x=sinus*0, y=sinus*1, z=sinus*) newPoint = q.rotate(poinToRotate) 

Rotation is somewhere good but it cube does not rotate around it self but around some point. But when

 p = Quaternion(w=0,x=0,y=0,z=0) 

to make it to the center, result is all zeros.

added 704 characters in body
Source Link

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

EDIT What I want is to rotate object on Y-axis using quaternion. So far,because of lack of my understanding, I m failing to rotate. I created a class 3dVector ->three dimensional vector, and instantiate a new position (0,0,-5). This position I sent as translate matrix to opengl and multiplied with glPosition.

When I tried to rotate that object using quaternion. I just took that position (0,0,-5) and used it in formula q = q * p * q(conjugate). I manually calculated that but result I get didnt make object rotate on Y-axis around itself. Now I m not sure, but I think it actually rotated object but not around him self,he was moved to the right, so he was not in the same position anymore

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?

EDIT What I want is to rotate object on Y-axis using quaternion. So far,because of lack of my understanding, I m failing to rotate. I created a class 3dVector ->three dimensional vector, and instantiate a new position (0,0,-5). This position I sent as translate matrix to opengl and multiplied with glPosition.

When I tried to rotate that object using quaternion. I just took that position (0,0,-5) and used it in formula q = q * p * q(conjugate). I manually calculated that but result I get didnt make object rotate on Y-axis around itself. Now I m not sure, but I think it actually rotated object but not around him self,he was moved to the right, so he was not in the same position anymore

Source Link

Understanding how to use Quaternion to rotate object

I m having hard time to understand Quaternions and to use them in my engine for rotating object. I m looking for step by step explanation, actually a correction of my view of Quaternions.

Here is how I understand they work.

q = cos(40*) + sin(40)(i+j+k)

->what I understand is that i+j+k represents the axis of rotation. Basically if i = 1 that means we rotate object around X-axis.

Formula q * point * p-1, is what I dont quite understand. Lets for the sake say I understand why forumla goes like this. What I dont seems to get how would I apply this to my engine to rotate object.

What I tried is to create 3dVector with object position, example (0,0,-5). I would use quaternion that would rotate this vector around y axis, so q * ThisVector * q(conjugate), and then result I would put in translate matrix. But no work. I cant seem to find a way to implement them. I saw some articles on quaternion to matrices, But what do I put in that matrix, a result from qThisVectorq(conjugate) or it is just q that is transfromed in matrix?