Advertisement

Rotations... I know its in the FAQ but...

Started by February 14, 2006 12:56 AM
-1 comments, last by Noobwaker 18 years, 8 months ago
When I rotated the 'camera' along the Y-axis about 90 degrees to the left, and then tried to rotate up I just got a clock-wise spin. So then I tried rotating the vectors that I use to rotate around, but somehow, I still get the clockwise spin. Can anyone tell me what I'm doing wrong? This is the code for my rotations and for my vector rotations.

	vec=RotVect(xcma,ycma,zcma,0.,1.,0.);
	glRotated(-ycma,vec.x,vec.y,vec.z);
	vec=RotVect(xcma,ycma,zcma,1.,0.,0.);
	glRotated(-xcma,vec.x,vec.y,vec.z);
	vec=RotVect(xcma,ycma,zcma,0.,0.,1.);
	glRotated(-zcma,vec.x,vec.y,vec.z);
Vect RotVect(double xa, double ya, double za, double x, double y, double z){
	Vect vt;
	double cy=cos(ya*deg), sy=sin(ya*deg), cx=cos(xa*deg), sx=sin(xa*deg), cz=cos(za*deg), sz=sin(za*deg);
	vt.x=  (x*cy+z*sy);
	vt.y=  (y);
	vt.z=  (-x*sy+z*cy);
	x= (vt.x);
	y= (vt.y*cx-vt.z*sx);
	z= (vt.y*sx+vt.z*cx);
	vt.x= (x*cz-y*sz);
	vt.y= (x*sz+y*cz);
	vt.z= (z);
	return vt;
}
double deg=M_PI/180.;

This topic is closed to new replies.

Advertisement