Finiding orientation of a rod

74 Views Asked by At

I have rod made with small spheres like thisenter image description here. All the spheres together make this rigid rod.I have coordinate of all small spheres in 3d thus I can be able to find out it's center of mass and most extreme point of both sides. The rod can rotate in $\theta$ and $\phi$ direction as per spherical coordinate system. enter image description here

So my question is how can I calculate both rotations from its initial position coordinates? What is the formula to calculate that if I have given only coordinates?

1

There are 1 best solutions below

0
On BEST ANSWER

Assuming we can simplify the shape to a cylinder and know the location of the center of each end cap, which are Cartesian coordinate points $p_1$ and $p_2$. We then choose one of the points as the origin and subtract it from the other, e.g. $p_0 = p_2 - p_1$. We then calculate $$ \theta = \arctan(p_{0_y} / p_{0_x}) $$ correcting for quadrant, of course.

To get $\phi$ we need to find $r = |{p_0}|$ or $ r=\sqrt{p_{0_x}^2+p_{0_y}^2+p_{0_z}^2}$ and then $$ \phi = \arccos(p_{0_z} / r ) $$

Note that if we had defined $p_0 = p_1 - p_2$ then $\theta$ and $\phi$ would both be 180° off.