Camera rotation
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.
Okay, quick question:
This is what I got from the code in the article, but for the others, does this part:
Stay the same? Or do I have to change the variables depending on what axis I'm rotating around?
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement