# Camera rotation

This topic is 4793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
I'm not sure I understand. They're already in functions for you. What exactly do you need?

##### Share on other sites
Don't worry, I figured it out. I missed a couple of crucial lines.

Thanks anyway.

##### 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?

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633755
• Total Posts
3013706
×