Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


The Problems about the FPS Camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 kamimail   Members   -  Reputation: 123

Like
0Likes
Like

Posted 21 March 2013 - 05:24 AM

Hi,every one,

   I am a novice in the 3D math.currently , I am tortured by a problem about the rotation of a FPS camera.hope someone can help me .

   please allow me to assume that the discussion is based on OpenGL conversion.

   suppose the FPS camera is placed at the initial state in which the three axis of camera are aligned with axis of world frame.

 

   I firstly pitch the camera around the x axis of world frame, and then yaw the camera around the y axis of world frame.so I can get the following equation(column-major) : 

   camera_orientation_matrix_1 = yaw_yworld_matrix * pitch_xworld_matrix =  rotateY(yaw_angle)  *  rotateX(pitch_angle);

 

   some reference  informs me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

   so I firstly yaw the camera with local y axis of camera, then pitch the camera around the local x axis of the camrea.

ie: camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

 

   since the  camera_orientation_matrix_1 equals camera_orientation_matrix _2, I derive the following:

        rotateY(yaw_angle)  *  rotateX(pitch_angle) === rotateX(pitch_angle) * rotateY(yaw_angle) ;

  but the above equation is a fallacy,Is there anyone can tell me where is wrong? Thanks! smile.png


Edited by kamimail, 21 March 2013 - 05:32 AM.


Sponsor:

#2 Ravnock   Members   -  Reputation: 289

Like
1Likes
Like

Posted 21 March 2013 - 05:30 AM

Hi,every one,

   I am a novice in the 3D math.currently , I am tortured by a problem about the rotation of a FPS camera.hope someone can help me .

   please allow me to assume that the discussion is based on OpenGL conversion.

   suppose the FPS camera is placed at the initial state in which the three axis of camera are aligned with axis of world frame.

 

   I firstly pitch the camera around the x axis of world frame, and then yaw the camera around the y axis of world frame.so I can get the following equation(column-major) : 

   camera_orientation_matrix_1 = yaw_yworld_matrix * pitch_xworld_matrix =  rotateY(yaw_angle)  *  rotateX(pitch_angle);

 

   some reference  informed me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

   so I firstly yaw the camera with local y axis of camera, then pitch the camera around the local x axis of the camrea.

ie: camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

 

   since the  camera_orientation_matrix_1 equals camera_orientation_matrix _2, I derive the following:

        rotateY(yaw_angle)  *  rotateX(pitch_angle) === rotateX(pitch_angle) * rotateY(yaw_angle) ;

  but the above equation is a fallacy,Is there anyone can tell me where is wrong? Thanks! smile.png

 

From Wikipedia (general case): For n greater than 2, multiplication of n×n rotation matrices is not commutative.

 

http://en.wikipedia.org/wiki/Rotation_matrix



#3 Ashaman73   Crossbones+   -  Reputation: 7822

Like
0Likes
Like

Posted 21 March 2013 - 05:33 AM

some reference informed me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

I think that this is some kind of missinterpretation. E.g. use an OO camera model, then you could do the following:

Camera.reset();
Camera.rotateAroundLocalY(yaw);
Camera.rotateAroundLocalX(pitch);

The trick is, that you rotate the second time around a modified axis (local axis) which no longer equals the global X axis, therefor you can't just use a rotateX matrix which uses the global axis. That's the reason your assumption

camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

is wrong.



#4 kamimail   Members   -  Reputation: 123

Like
0Likes
Like

Posted 21 March 2013 - 05:37 AM

#2

 

 

Hi,every one,

   I am a novice in the 3D math.currently , I am tortured by a problem about the rotation of a FPS camera.hope someone can help me .

   please allow me to assume that the discussion is based on OpenGL conversion.

   suppose the FPS camera is placed at the initial state in which the three axis of camera are aligned with axis of world frame.

 

   I firstly pitch the camera around the x axis of world frame, and then yaw the camera around the y axis of world frame.so I can get the following equation(column-major) : 

   camera_orientation_matrix_1 = yaw_yworld_matrix * pitch_xworld_matrix =  rotateY(yaw_angle)  *  rotateX(pitch_angle);

 

   some reference  informed me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

   so I firstly yaw the camera with local y axis of camera, then pitch the camera around the local x axis of the camrea.

ie: camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

 

   since the  camera_orientation_matrix_1 equals camera_orientation_matrix _2, I derive the following:

        rotateY(yaw_angle)  *  rotateX(pitch_angle) === rotateX(pitch_angle) * rotateY(yaw_angle) ;

  but the above equation is a fallacy,Is there anyone can tell me where is wrong? Thanks! smile.png

 

From Wikipedia (general case): For n greater than 2, multiplication of n×n rotation matrices is not commutative.

 

http://en.wikipedia.org/wiki/Rotation_matrix

Hi, Ravnock, thanks for your reply.

I don't know where is wrong in my above inference.hope someone can pinpoint it to me.



#5 Ashaman73   Crossbones+   -  Reputation: 7822

Like
0Likes
Like

Posted 21 March 2013 - 05:38 AM

Hi,every one,

   I am a novice in the 3D math.currently , I am tortured by a problem about the rotation of a FPS camera.hope someone can help me .

   please allow me to assume that the discussion is based on OpenGL conversion.

   suppose the FPS camera is placed at the initial state in which the three axis of camera are aligned with axis of world frame.

 

   I firstly pitch the camera around the x axis of world frame, and then yaw the camera around the y axis of world frame.so I can get the following equation(column-major) : 

   camera_orientation_matrix_1 = yaw_yworld_matrix * pitch_xworld_matrix =  rotateY(yaw_angle)  *  rotateX(pitch_angle);

 

   some reference  informed me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

   so I firstly yaw the camera with local y axis of camera, then pitch the camera around the local x axis of the camrea.

ie: camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

 

   since the  camera_orientation_matrix_1 equals camera_orientation_matrix _2, I derive the following:

        rotateY(yaw_angle)  *  rotateX(pitch_angle) === rotateX(pitch_angle) * rotateY(yaw_angle) ;

  but the above equation is a fallacy,Is there anyone can tell me where is wrong? Thanks! smile.png

 

From Wikipedia (general case): For n greater than 2, multiplication of n×n rotation matrices is not commutative.

 

http://en.wikipedia.org/wiki/Rotation_matrix

Though this is not a proof, that a certain sub-set of nxn matrices is not commutative. E.g. the set of all pure homogenes 4x4 translation matrices are commutative.

Hehe, the above statement is at least a proof, that I fail to read carefully a post sometimes rolleyes.gif


Edited by Ashaman73, 21 March 2013 - 05:41 AM.


#6 Ravnock   Members   -  Reputation: 289

Like
0Likes
Like

Posted 21 March 2013 - 05:50 AM

 

 

 

Hi,every one,

   I am a novice in the 3D math.currently , I am tortured by a problem about the rotation of a FPS camera.hope someone can help me .

   please allow me to assume that the discussion is based on OpenGL conversion.

   suppose the FPS camera is placed at the initial state in which the three axis of camera are aligned with axis of world frame.

 

   I firstly pitch the camera around the x axis of world frame, and then yaw the camera around the y axis of world frame.so I can get the following equation(column-major) : 

   camera_orientation_matrix_1 = yaw_yworld_matrix * pitch_xworld_matrix =  rotateY(yaw_angle)  *  rotateX(pitch_angle);

 

   some reference  informed me that I can get the same orientation by using the local rotation matrix but applied in a reverse order.

   so I firstly yaw the camera with local y axis of camera, then pitch the camera around the local x axis of the camrea.

ie: camera_orientation_matrix _2 = pitch_xlocal_matrix * yaw_ylocal_matrix = rotateX(pitch_angle) * rotateY(yaw_angle) ;

 

   since the  camera_orientation_matrix_1 equals camera_orientation_matrix _2, I derive the following:

        rotateY(yaw_angle)  *  rotateX(pitch_angle) === rotateX(pitch_angle) * rotateY(yaw_angle) ;

  but the above equation is a fallacy,Is there anyone can tell me where is wrong? Thanks! smile.png

 

From Wikipedia (general case): For n greater than 2, multiplication of n×n rotation matrices is not commutative.

 

http://en.wikipedia.org/wiki/Rotation_matrix

Hi, Ravnock, thanks for your reply.

I don't know where is wrong in my above inference.hope someone can pinpoint it to me.

 

I have not idea about OpenGL but I use to build my rotation matrix with the D3DXMatrixLookAtRH function, I think gluLookAt it's similar. You set where you are, where are you looking at and the up axis, for a FPS is everything you need...






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS