Rotation questions

Posted By: Richey

Rotation questions - 11/19/07 21:06

I am having a few problems getting to grips with rotations. I am trying to position an entity at an off set to another entity. If I want to place the child entity directly infront of the parent entity i use

Code:

var dir_x[3];
vec_for_angle(dir_x, parent.pan);
child.x = parent.x + (dir[0] * distance);
child.y = parent.y + (dir[1] * distance);
child.z = parent.z + (dir[2] * distance);



This positions the child 'distance' quants infront of the parent no matter what the rotation of the parent.

I cannot work out how to do this to place the child at the side or above the parent? I have tried rotation the direction vector (dir_x) using vec_rotate (dir_x, vector(90,0,0)) to make it face 'left' but although it starts in the correct location when I alter the tilt of the parent the child rotates around it in 2 axis?
Posted By: Fenriswolf

Re: Rotation questions - 11/19/07 21:17

Hi,

you can do this with the following code:

var dir_x[3];
vec_set(dir_x, vector(distance, 0, 0));
vec_rotate(dir_x, parent.pan);
vec_add(dir_x, parent.x);
vec_set(child.x, dir_x);
Posted By: Richey

Re: Rotation questions - 11/20/07 00:00

Very useful. Thank you.

I've been playing around with that and it seems to be what I need.

If I am correct if I use vec_set(dir_x, vector(50,0,50)); I will get a point 50 quants ahead and 50 quants above?
Posted By: Fenriswolf

Re: Rotation questions - 11/20/07 08:50

Quote:

If I am correct if I use vec_set(dir_x, vector(50,0,50)); I will get a point 50 quants ahead and 50 quants above?



Yes, exactly.
© 2024 lite-C Forums