Vector to angles
Hi all.
I have defined a camera B-Spline path. I know the tangent vector is the velocity and the camera direction in some fraction time. Here is the question: How can I convert the tangent vector (x, y, z) to angles (pitch, yaw and roll)??. I tried with this but it doesn''t work correctly:
void GetAnglesFromVector(D3DVECTOR *v, float *pitch, float *yaw, float *roll)
{
// pitch
// first cuad.
if(v->y > 0.0f && v->z > 0.0f)
*pitch = acosf(v->z);
// second cuad.
if(v->y > 0.0f && v->z < 0.0f)
*pitch = acosf(v->z);
// third cuad.
if(v->y < 0.0f && v->z < 0.0f)
*pitch = acosf(v->z);
// fourth cuad.
if(v->y < 0.0f && v->z > 0.0f)
*pitch = acosf(v->z);
// yaw
// first cuad.
if(v->x > 0.0f && v->z > 0.0f)
*yaw = acosf(v->x);
// second cuad.
if(v->x < 0.0f && v->z > 0.0f)
*yaw = acosf(v->x);
// third cuad.
if(v->x < 0.0f && v->z < 0.0f)
*yaw = acosf(v->x);
// fourth cuad.
if(v->x > 0.0f && v->z < 0.0f)
*yaw = acosf(v->x);
// roll
// first cuad.
if(v->x > 0.0f && v->y > 0.0f)
*roll = acosf(v->x);
// second cuad.
if(v->x < 0.0f && v->y > 0.0f)
*roll = acosf(v->x);
// third cuad.
if(v->x < 0.0f && v->y < 0.0f)
*roll = acosf(v->x);
// fourth cuad.
if(v->x > 0.0f && v->y < 0.0f)
*roll = acosf(v->x);
}
Do you know some better way to make this??
You can download the demo <A HREF="http://www.arrakis.es/~jonathan01/b-spline.zip>here.
Thankx a lot.
I dunno. This message board thing is screwed up!!!
I wonder what happens to my message?
TESTING, 123...
ROW 1
ROW 2
ROW 3
ROW 4
ROW 5
ROW 6
ROW 7
ROW 8
ROW 9
ROW 10
Intriguing!
/Memir
I wonder what happens to my message?
TESTING, 123...
ROW 1
ROW 2
ROW 3
ROW 4
ROW 5
ROW 6
ROW 7
ROW 8
ROW 9
ROW 10
Intriguing!
/Memir
I have the feeling that this message will appear on the R.H.S of my message...
I guess theres only one way to find out!!!
/Memir
I guess theres only one way to find out!!!
/Memir
BeRSeRKeR:
You forgot to type a " in your first link:
b-spline.zip>here // wrong
b-spline.zip">here // good!
Edit your message to correct it.
You forgot to type a " in your first link:
b-spline.zip>here // wrong
b-spline.zip">here // good!
Edit your message to correct it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement