How to calculate obtuse angle between two vectors?

How to calculate the obtuse angle between two vectors if both vectors and the x axis are given. The first vector can be taken as the x axis. we can sharpen with the help of a point product and acos.

+3
source share
2 answers

Before using acos, check if the dot product is negative. If negative, the angle is dumb :)

Also, since acos has a range from 0 to pi, you will do your best until you want to reflect angles (> pi)

+4
source

For the correct resolution of the angle, it is necessary to use both point and cross products. The angle between the vectors u and v is

||atan2(s,c)||
where `s = ||u X v||`  (magnitude of the cross product)
and `c = u.v`        (dot product)

and atan2- 4-quadrant inverse tan-function

||*|| ().

0 180 .

0

Source: https://habr.com/ru/post/1719371/


All Articles