当前位置:网站首页>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 
边栏推荐
- Detailed sorting of HW blue team traceability process
- To solve the difficulties of small and medium-sized enterprises, Baidu AI Cloud makes an example
- 2. Introduction to parallel interface, protocol and related chips (8080, 8060)
- 古瑞瓦特冲刺港交所上市:创下“多个第一”,获IDG资本9亿元投资
- Electron official docs series: Examples
- 遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名
- Mysql database explanation (IV)
- HDU 3709 Balanced Number
- 适配器模式(Adapter)
- Use of wangeditor rich text editor
猜你喜欢

MySQL explanation (I)

Chapter 10 setting up structured logging (2)

Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value

创建一个自己的跨域代理服务器

Echart stack histogram: add white spacing effect setting between color blocks

Input text to automatically generate images. It's fun!

Teacher Li Hang's new book "machine learning methods" is on the market! Purchase link attached

防火墙介绍

Es snapshot based data backup and restore

MySQL讲解(二)
随机推荐
5+api, clear application cache
Electron official docs series: Distribution
Decorator
CloudCompare——泊松重建
Bigint: handles large numbers (integers of any length)
Log in to the server using SSH key pair
Reflect the technical depth (unable to speed up)
Network remote access using raspberry pie
[how to connect the network] Chapter 2 (next): receiving a network packet
嵌入式virlog代码运行流程
Electron official docs series: Examples
网络远程访问的方式使用树莓派
HDU 3555 Bomb
Enjoy element mode (flyweight)
Electron official docs series: Best Practices
Lamp compilation and installation
Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value
To solve the difficulties of small and medium-sized enterprises, Baidu AI Cloud makes an example
mysql讲解(一)
I have a good word to say, and I admire myself