# Rotation errors

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

## Recommended Posts

Hi people. I'm creating this camera class which i want to combine usability of world system coordinates and local rotations. I've encountered very strange results and can't quite pinpoint the source of the problem.
class CCam
{
public:
// constructors, destructors
CCam() {}
CCam(float px, float py, float pz, float ax, float ay, float az, float ux, float uy, float uz)
{
pos.x = px;
pos.y = py;
pos.z = pz;

at.x = ax;
at.y = ay;
at.z = az;

up.x = ux;
up.y = uy;
up.z = uz;

at = at-pos;
at.Normalize();
at = pos+at;
up.Normalize();
up=pos+up;
side = (up - pos)^(at-pos);
side.Normalize();
side = side + pos;
up = (at - pos)^(side - pos);
up.Normalize();
up = up + pos;

}
~CCam() {}

void Pitch(float angle) // dunno if this is correct english name - it is supposed to be rotation of 'at' vector about 'up' vector ;)
{

at = at - pos;
up = up - pos;
at = at.Rotate(angle, up);

at.Normalize();
at = pos + at;
up = up + pos;
side = (up - pos)^(at-pos);
side.Normalize();
side = side + pos;
}


Oh yeah, my vector cross product, magnitude and normalize methods look like this (maybe the error's here?):
        CVector operator^(const CVector &v) const   { return CVector(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);}
float Magnitude() const			    { return sqrt(x*x + y*y + z*z);}
void Normalize()			    { if(Magnitude() != 0)*this /= Magnitude();}


Any help would be welcome :)

##### Share on other sites
It was actually Yaw, not Pitch - google to the rescue ;)

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013604
×