3d force vectors
I need help i cant seem to solve this problem
this is the data i have to work with
struct{
float xy,xz,yz,mag
}
from this i need to find the x y and z components of the vector
oh ya the xy,xz,yz are the angles of the vector. they are the angle of the line from 0,0,0 to there respective component so xy is the angle of the line from 0,0 to the xy end point of the vector. but i do not knoe the end point of the vector just its length.
thnx.
my def of program - a waltz that moves to a beat it seems only i can hear. And when i find a other who can here the beat i will find my place.
I'm not sure about this, but isn't that information a bit redundant. If AB from {xy,xz,yz} is angle of line projectd on AB plane, then one of those can be expresed with the other two. So to get normal 3D vector you would use two of them as spherical cordinats to create normalized vector and then multiply it with mag to get the final one.
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on February 14, 2004 12:57:58 PM]
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on February 14, 2004 12:57:58 PM]
You should never let your fears become the boundaries of your dreams.
darkwing is right, but I think all you need is a little lesson
on trig. Lets see if this makes sense to you:
First off, there is no such thing as an angle from a point,
angles are between lines or planes. So lets specify something,
you probably meant that the "angle" xy is in the XY-plane & its
referenced from the positive X-axis (the most intuitive one).
So in this case:
X = cos( xy );
Y = sin( xy );
so now you have the X & Y components of your vector. Now we
need to assume something about the variable "xz", lets say that
its the component of your vector in the XZ-plane of course, &
lets say that its referenced from the positive X-axis (again).
So...
Z = -sin( xz);
Notice I never used "yz" its not needed. You only need 2 of
these 3 like darkwing said. Also, if you want to use this
vector in a gl function call like glNormal3f(), than you might
want to normalize it, because you already have the magnitude &
that would be quick, just do this:
Most of this follows the right-hand rule. If none of what I just said makes sense to you... go take a math course or go pick up a book on trig. I never took trig in HS, but I read a book on it one summer before I took calc & its not all that hard.
[edited by - Luke Miklos on February 14, 2004 3:19:17 PM]
on trig. Lets see if this makes sense to you:
First off, there is no such thing as an angle from a point,
angles are between lines or planes. So lets specify something,
you probably meant that the "angle" xy is in the XY-plane & its
referenced from the positive X-axis (the most intuitive one).
So in this case:
X = cos( xy );
Y = sin( xy );
so now you have the X & Y components of your vector. Now we
need to assume something about the variable "xz", lets say that
its the component of your vector in the XZ-plane of course, &
lets say that its referenced from the positive X-axis (again).
So...
Z = -sin( xz);
Notice I never used "yz" its not needed. You only need 2 of
these 3 like darkwing said. Also, if you want to use this
vector in a gl function call like glNormal3f(), than you might
want to normalize it, because you already have the magnitude &
that would be quick, just do this:
X /= mag; //X = X/mag;Y /= mag; //Y = Y/mag;Z /= mag; //Z = Z/mag;
Most of this follows the right-hand rule. If none of what I just said makes sense to you... go take a math course or go pick up a book on trig. I never took trig in HS, but I read a book on it one summer before I took calc & its not all that hard.
[edited by - Luke Miklos on February 14, 2004 3:19:17 PM]
Whatsoever you do, do it heartily as to the Lord, and not unto men.
Are you saying that xy, xz, and yz are rotations along the primary axis to get to your new point? Like xy is a rotation around the z axis, xz rotation around the y axis and yz rotation around the x?
If that is the case, you might be able to use openGL functions to do the math for you.
Then your vector is x = matrix[12], y = matrix[13], z = matrix[14];
Essentially you are rotating to the direction of your new point from 0,0,0 and then translating to it by the magnitude.
If that is the case, you might be able to use openGL functions to do the math for you.
glPushMatrix();glLoadIdentity();glRotatef(xy,0,0,1);glRotatef(xz,0,1,0);glRotatef(yz,1,0,0);glTranslatef(0,0,mag);float matrix[16];glGet(GL_MODEL_MATRIX,matrix); ...I think this is the callglPopMatrix();
Then your vector is x = matrix[12], y = matrix[13], z = matrix[14];
Essentially you are rotating to the direction of your new point from 0,0,0 and then translating to it by the magnitude.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement