Traditional Culture Encyclopedia - Traditional customs - How to find the rotation angle between two vectors in space? The angle range is 0-360 degrees.
How to find the rotation angle between two vectors in space? The angle range is 0-360 degrees.
Given two three-dimensional space vectors, find the rotation angle of one vector counterclockwise to the other vector, which is in the range of 0-360.
(1) The included angle of two vectors obtained from the formula.
(2) Judging the rotation direction according to the cross product.
Three o'clock on the plane:?
p 1(x 1,y 1)? –& gt; Vertex,?
p2(x2,y2)? –& gt; Vertex,?
p3(x3,y3)? –& gt; Origin,
s(p 1,p2,P3)=(x 1-x3)*(y2-y3)-(x2-x3)*(y 1-y3)
If s>0 indicates that three points are connected in counterclockwise order. If it is s
Two-dimensional vector cross product
Let the vector P = (x 1, y 1) and Q = (x2, y2).
Then the vector cross product is defined as: P × Q = x 1*y2-x2*y 1? What you get is a scalar, which is the signed area of a parallelogram.
Obviously, it has the property of P × Q =-(Q × P)? P × ( - Q ) = - ( P × Q)
Unless otherwise specified, all the following points are regarded as vectors, and the product of points is regarded as vector cross product;
Important properties of cross product:
& gt if P × Q > 0, then p is in the clockwise direction of q.
& gt if p × q
& gt if P × Q = 0, then p and q are * * * lines, but they may be in the same direction or in opposite directions.
(1) two-dimensional vector
Just as the dot product is proportional to the cosine of an angle, a determinant is proportional to its sine. So you can calculate the angle like this:
dot = x 1*x2 + y 1*y2? Dot product between # x 1, y 1 and [x2, y2] det = x1* y2-y1* x2? # determinantangle = atan2(det,dot)? # atan2(y, x) or atan2(sin, cos)
The direction of the angle matches the direction of the coordinate system. In the left-handed coordinate system, which is common in computer graphics, X refers to the right and Y goes down, which means you get the plus sign of clockwise angle. If the direction of the coordinate system is the y direction of mathematics, the counterclockwise angle is obtained, just like the convention in mathematics. Changing the order of input will change the symbols, so if you are not satisfied with the symbols, exchange the inputs.
Atan 2 is more stable than Atan.
In the mathematical coordinate system, atan2? A positive result indicates the angle of counterclockwise rotation from the X axis, and a negative result indicates the angle of clockwise rotation from the X axis.
(2) Three-dimensional vector
In 3D, two arbitrarily placed vectors define their own axes of rotation, and they are both perpendicular to these two vectors. The axis of rotation has no fixed direction, which means that you cannot uniquely fix the direction of rotation. The usual practice is to keep the angle always positive and determine the direction of the shaft in a way suitable for the positive angle. In this case, the dot product of the normalized vector is enough to calculate the angle.
Dot = x1* x2+y 1 * y2+z1* z2 # between [x1,y1,z 1] and [x2, y2, z2]lens q 1 = x 1 * x 1+y 1 * y 1+z 1 * z 6538
lenSq2 = x2*x2 + y2*y2 + z2*z2
angle = acos(dot/sqrt(lensq 1 * lensq 2))
- Previous article:Methods and means of making plates
- Next article:Beijing Gongmei Group is a state-owned enterprise or a centralized enterprise
- Related articles
- How to thoroughly gastric lavage?
- 2019 Chengdu "Rongcheng Autumn" Music Season activities to see
- Traditional Culture Around Me 400 Words 4th Grade
- Try to analyze the specific manifestations of "feminization" and "southernization" of Tang and Song lyrics by taking specific works as examples.
- What kind of person is Sun Heting?
- What Chinese songs are there?
- Is the lead content of preserved eggs really high? Can I eat two a day?
- Jinshi Dian Hong tea brewing method
- The patterns on ancient people's clothes are very beautiful. What are the models?
- The winter solstice is one of the most important festivals of the year, what are the traditional diets for the winter solstice?