vector $\tilde a = c\tilde i+d\tilde j+e\tilde k$ is our input, and vector $\tilde b = f\tilde i+g\tilde j+h\tilde k$ is our output, and $\theta$ is the angle to rotate by. Essentially $\tilde b = f(\tilde a, \theta)$

This is similar to Components of a 3d vector given specific angles, but I need to rotate the vector on the plane created by $\tilde a$ and $\tilde j$.

I attempted to create a function by converting $\tilde a$ to a 2d point on this plane:
$(x, y) = (\sqrt{1-d^2}, d)$
converting to a polar coordinate, adding alpha, converting back to cartesian, and taking the $y$ component as the value for $g$:

$$g = \sqrt{d^2+\sqrt{1-d^2}} \times \sin\bigg(\tan^{-1}\Big(\frac{d}{\sqrt{1-d^2}}\Big)\bigg)$$ $$f = \frac {c \times\sqrt{1-d^2}} {\sqrt{c^2+e^2}}$$ $$h = \frac {e\times f}{c}$$

This formula produces unexpected results when given a value close to $\pm\tilde j$, eg. $f(0.174126\tilde i+0.984723\tilde j, \frac {-\pi}{16})$ returns $g = 0.996584$ which is higher the input value of $d=0.984723$. The expected value is aproximately $g=0.779171$ (I think). Continuing to tilt the resulting $\tilde b$ by $\frac{-\pi}{16}$, cases $g$ to aproach $0.996$ ish.

Can anyone spot my error, or find a better way of doing this?

  • $\begingroup$ Find the angle of rotation by dot multiplication. Why moving to 2D? $\endgroup$ – Moti Mar 24 at 6:32
  • $\begingroup$ @Moti because f and h can be found from a and g, and 2d allowed me to use radial coordinates which (I think) did exactly what I want, just in 2d $\endgroup$ – Alice Jacka Mar 24 at 7:05
  • $\begingroup$ @Moti could you elaborate on the dot multiplication? $\endgroup$ – Alice Jacka Mar 24 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.