Jump to content
  • Advertisement
Sign in to follow this  
Endar

Camera rotation

This topic is 4616 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

I'm attempting to understand the rotation equations given here in an NeHe article, but I'm not quote there. Could someone explain it for me? Especially the "optimized" equations, because I'm not completely sure how to turn them into functions.

Share this post


Link to post
Share on other sites
Advertisement
Okay, quick question:


void rotateYRadians(float amount)
{
/*
x' = m1x + l1z
z' = m3x + l3z
*/


util::CVector3d target = m_target;
util::CVector3d right = m_right;

float cosine_amount = cos(amount);
float cosine_halfpi_plus_amount = cos((PI/2) + amount);
float cosine_halfpi_minus_amount = cos((PI/2) - amount);

m_target.x = (cosine_halfpi_plus_amount * target.x) + (cosine_amount * right.x);
m_target.y = (cosine_halfpi_plus_amount * target.y) + (cosine_amount * right.y);
m_target.z = (cosine_halfpi_plus_amount * target.z) + (cosine_amount * right.z);

m_right.x = (cosine_amount * target.x) + (cosine_halfpi_minus_amount * right.x);
m_right.y = (cosine_amount * target.y) + (cosine_halfpi_minus_amount * right.y);
m_right.z = (cosine_amount * target.z) + (cosine_halfpi_minus_amount * right.z);

m_target.normalize();
m_right.normalize();
}



This is what I got from the code in the article, but for the others, does this part:

float cosine_amount = cos(amount);
float cosine_halfpi_plus_amount = cos((PI/2) + amount);
float cosine_halfpi_minus_amount = cos((PI/2) - amount);


Stay the same? Or do I have to change the variables depending on what axis I'm rotating around?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!