How to find the amount of degrees to rotate a vector to be 90 degrees another vector?

277 Views Asked by At

I have a vector V that rotates around an axis K and a vector N all in 3D space. I need to find how much to rotate the vector V around S so that it lies 90 degrees to N. So far I have been doing it through brute force (have written a program that adds a degree rotation and tests) but I feel like there must be a more direct method.

1

There are 1 best solutions below

0
On BEST ANSWER

You can write $N$ as a sum of a parallel component $N_\parallel=(N\cdot K)K$ and a perpendicular component $N_\perp=N-N_\parallel=N-(N\cdot K)K$ (assuming that $K$ is normalized). Then rotating through an angle $\phi$ yields $N'=N_\parallel+N_\perp\cos\phi+(K\times N_\perp)\sin\phi$, where $K\times N_\perp=K\times(N-(N\cdot K)K)=K\times N$. Your condition is $V\cdot N'=0$, so this is

$$ V\cdot((N\cdot K)K+(N-(N\cdot K)K)\cos\phi+(K\times N)\sin\phi)=0\;. $$

You can solve this equation for $\phi$ e.g. by taking the $\sin\phi$ term to the other side, squaring, using $\sin^2\phi=1-\cos^2\phi$, solving the resulting quadratic for $\cos\phi$ and then obtaining the sign for $\phi$ from the unsquared equation.