Unity calculates the straight-line distance between two points

Unity calculates the straight-line distance between two points

Vector3 P1 = New Vector3(1,1,1);
Vector3 P2 = New Vector3(2,2,2);
print((P1 - P2).magnitude);//两点距离
print((P1 - P2).sprmagnitude);//两点距离平方

Using quaternions to find the angle between two points

Quayernion q1 = new Quaternion(0,0,0,1.0f);
Quayernion q2 = new Quaternion(0.1f,0.4f,-0.9f,-0.2f);
float angle = Quaternion.Angle(q1,a2);

Guess you like

Origin blog.csdn.net/Chj1319261607/article/details/129321600