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?