Sign in to follow this  

Camera rotation

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

This topic is 4423 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this