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

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

## 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 on other sites
... 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 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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013231
×