Jump to content
  • Advertisement
Sign in to follow this  
ElijahEwing

finding a point with a given direction and distance [help me]

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

sorry if this is in the wrong section, i am new here, so anyway here is my problem.
currently I am developing a rendering engine (mostly for making models to insert into a game), inside this engine I have a class (designed for making vector points) when you use this you set a distance and direction relative to a point (the bone joint) it then sets the XYZ points depending on the given rotation and distance. Here is the coding so far
public class Vec
{
//their dropin us presents... why are they explodin???
int distanceToJoint;
int directionToJointY;
int directionToJointX;
int directionToJointZ;
int xpos;
int ypos;
int zpos;
SkelBone skel;
public Vec (int ds, int dry, int drx,int drz, SkelBone sk)
{
distanceToJoint = ds;
directionToJointY = dry;
directionToJointX = drx;
directionToJointZ = drz;
skel = sk;
}
}

basically I need to find a way to set xpos, ypos and zpos

Share this post


Link to post
Share on other sites
Advertisement
... Sorry, what?

Please organize your thoughts and ask your question more clearly. What do you know? What don't you know? What are the inputs and outputs to your process?

Share this post


Link to post
Share on other sites
are drx/dry/drz euler angles? First I think you will definately need to change most of those values to being floats and not ints. My guess is your bone is at (0, 0, 0) initially, you want to rotate it by the given angles and find the end point (storing those in xpos/ypos/zpos). This is not a difficult task if you have some maths things to use (matrices/vectors). Do you have anyhting like that?

I'd look at using a math lib, if not then make a Vector class and a function that takes euler angles and a vector, rotates by those angles and returns a rotated vector (that will be a fair amount of work). Then you can do:

Vector pos;
SkelBone skel;
public Vec (int ds, int dry, int drx,int drz, SkelBone sk)
{
distanceToJoint = ds;
directionToJointY = dry;
directionToJointX = drx;
directionToJointZ = drz;
skel = sk;
pos = new Vector(0, 0, distanceToJoint); // This would be the default "forward", where the bone points with no rotation
pos = RotateFromEulerAngles(drx, dry, drz, pos);
}


Vector RotateFromEulerAngles(float xr, float yr. float zr, Vector in);

To implement that you will need to know a bit of maths. Do you know matrix multiplication (there may be other ways)? This shows a general matrix for rotations: http://en.wikipedia.org/wiki/Rotation_matrix#Rotations_in_three_dimensions

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!