Camera rotation

Started by
2 comments, last by Endar 18 years, 5 months ago
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
I'm not sure I understand. They're already in functions for you. What exactly do you need?

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Don't worry, I figured it out. I missed a couple of crucial lines.

Thanks anyway.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper

This topic is closed to new replies.

Advertisement