0
$\begingroup$

I have a vector and a point $(x, y)$. The vector starts from $(0, 0)$ and goes to $(x_1, y_1)$. $x$, $y$, $x_1$, $y_1$ are known. How can I get the degree that vector should rotate clockwise to face this point? Scheme

$\endgroup$
  • $\begingroup$ Trigonometry; apply it to vector from $(0,0)$ to $(x,y)$ to compute $\text {cos}(\theta)$ and find the angle $\theta$. The same for the other one, finding $\theta_1$. $\endgroup$ – Mauro ALLEGRANZA Mar 21 at 15:05
0
$\begingroup$

You have an another vector $\vec A$ which joins $(0,0)$ and $(x,y)$. So now simply calculate the angle between this factor and your vector using dot product. You have: $ cos \theta = \frac{xx_1+yy_1}{\sqrt{x^2+y^2}\sqrt{x_1^2+y_1^2}}$ Where $\theta$ is angle between the two vectors

$\endgroup$
  • $\begingroup$ This returns cosine of angle in range [0°; 180°] (smallest angle of two possible). How can I get only clockwise angle (in range [0°; 360°] or [-180°; 180°])? $\endgroup$ – Grigory Panko Mar 21 at 17:12
  • $\begingroup$ This can be determined on the basis of in which quadrant do $(x,y)$ and $(x_1,y_1)$ lie. So based on their relative position(you will have various cases), you can get the clockwise angle in terms of $\theta$ :) $\endgroup$ – Tojrah Mar 21 at 17:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.