Trigonometry - Calculate 3D position of objects by their offset

900 Views Asked by At

I have object in 3D space (x,y,z and angles rx,ry,rz). How can i calculate coordinates of the 2nd object if i know 2nd object offset (x,y,z if 1st object rx,ry,rz are 0.0) from center of 1st object? Object angles are the same. Rotation is counter-clockwise.

Thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

x = x + offset_x * cos_ry * cos_rz - offset_x * sin_rx * sin_ry * sin_rz - offset_y * cos_rx * sin_rz + offset_z * sin_ry * cos_rz + offset_z * sin_rx * cos_ry * sin_rz;

y = y + offset_x * cos_ry * sin_rz + offset_x * sin_rx * sin_ry * cos_rz + offset_y * cos_rx * cos_rz + offset_z * sin_ry * sin_rz - offset_z * sin_rx * cos_ry * cos_rz;

z = z - offset_x * cos_rx * sin_ry + offset_y * sin_rx + offset_z * cos_rx * cos_ry;