当前位置:网站首页>Included angle of 3D vector
Included angle of 3D vector
2022-06-26 13:32:00 【Eat bones without spitting out femoral head skin】
Project scenario :
Calculate the included angle of three-dimensional coordinates
The included angle of three-dimensional vector
Reference resources :[ Online calculation of three-dimensional vector angle ](https://www.23bei.com/tool/300.html)
The formula :
The formula for calculating the included angle of three-dimensional vector is as follows :
Suppose that the two three-dimensional vectors are :a=(x1,y1,z1),b=(x2,y2,z2).
vector a The mold :|a|=√(x12+y12+z1^2).
vector b The mold :|b|=√(x22+y22+z2^2).
Dot multiplication of two vectors :a·b=(x1x2+y1y2+z1z2).
Let the angle between two vectors be θ, Then there are :cosθ=(x1x2+y1y2+z1z2)/[√(x12+y12+z12)*√(x22+y22+z22)].
The above formulas are given in three-dimensional coordinates , If you let the coordinate in z=0, Then we get the calculation formula of the plane vector . Angle between two vectors θ The range of phi is zero :[0,π]. When the included angle is an acute angle ,cosθ>0; When the included angle is an obtuse angle ,cosθ<0.
Three dimensional point coordinates
public class Point {
public float x;
public float y;
public float z;
public Point (float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
}
Calculation formula
/** * Get the included angle of the three-dimensional vector . * * @param center Included angle center point * @param start The starting point * @param end The end point * @return Return included angle */
public static float getTdAngle(Point center, Point start, Point end) {
// vector 1
float x1 = start.x - center.x, y1 = start.y - center.y, z1 = start.z - center.z;
// vector 2
float x2 = end.x - center.x, y2 = end.y - center.y, z2 = end.z - center.z;
System.out.println("x1/y1/z1=" + x1 + "/" + y1 + "/" + z1);
System.out.println("x2/y2/z2=" + x2 + "/" + y2 + "/" + z2);
// Dot product of vector
float vectorDot = x1*x2 + y1*y2 + z1*z2;
// vector 1 The mold
double vectorMold1 = Math.sqrt(Math.pow(x1, 2) + Math.pow(y1, 2) + Math.pow(z1, 2));
// vector 2 The mold
double vectorMold2 = Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2) + Math.pow(z2, 2));
// The angle of the vector [0, PI], When the included angle is an acute angle ,cosθ>0; When the included angle is an obtuse angle ,cosθ<0
double cosAngle = vectorDot / (vectorMold1 * vectorMold2);
double radian = Math.acos(cosAngle);
return (float) (180 / Math.PI * radian);
}
test result 
边栏推荐
- ES6 module
- Map value
- 古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
- Electron official docs series: Development
- KITTI Detection dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
- GO语言-管道channel
- Detailed sorting of HW blue team traceability process
- Reflect the technical depth (unable to speed up)
- Firewall introduction
- Design of simple digital circuit traffic light
猜你喜欢
随机推荐
H5 video automatic playback and circular playback
ES6 module
[node.js] MySQL module
MySQL数据库讲解(五)
[how to connect the network] Chapter 2 (next): receiving a network packet
Input text to automatically generate images. It's fun!
Chapter 10 setting up structured logging (2)
网络远程访问的方式使用树莓派
Nexys A7开发板资源使用技巧
B - Bridging signals
H5视频自动播放和循环播放
awk工具
Mysql database explanation (III)
There are many contents in the widget, so it is a good scheme to support scrolling
H - Sumsets POJ 2229
Composite mode
Detailed sorting of HW blue team traceability process
Analysis of state transition diagram of Beifu NC axis
7-2 picking peanuts
创建一个自己的跨域代理服务器








