mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
cosmetics
This commit is contained in:
@@ -44,20 +44,19 @@ namespace OpenSim.Framework
|
|||||||
// The point is an absolute position, so we need the relative
|
// The point is an absolute position, so we need the relative
|
||||||
// location to the spawn point
|
// location to the spawn point
|
||||||
Vector3 offset = point - pos;
|
Vector3 offset = point - pos;
|
||||||
Distance = Vector3.Mag(offset);
|
Distance = offset.Length();
|
||||||
|
|
||||||
// Next we need to rotate this vector into the spawn point's
|
// Next we need to rotate this vector into the spawn point's
|
||||||
// coordinate system
|
// coordinate system
|
||||||
rot.W = -rot.W;
|
rot.W = -rot.W;
|
||||||
offset *= rot;
|
offset *= rot;
|
||||||
|
offset.Normalize();
|
||||||
Vector3 dir = Vector3.Normalize(offset);
|
|
||||||
|
|
||||||
// Get the bearing (yaw)
|
// Get the bearing (yaw)
|
||||||
Yaw = MathF.Atan2(dir.Y, dir.X);
|
Yaw = MathF.Atan2(offset.Y, offset.X);
|
||||||
|
|
||||||
// Get the elevation (pitch)
|
// Get the elevation (pitch)
|
||||||
Pitch = -MathF.Atan2(dir.Z, MathF.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
|
Pitch = -MathF.Atan2(offset.Z, MathF.Sqrt(offset.X * offset.X + offset.Y * offset.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 GetLocation(Vector3 pos, Quaternion rot)
|
public Vector3 GetLocation(Vector3 pos, Quaternion rot)
|
||||||
@@ -65,8 +64,8 @@ namespace OpenSim.Framework
|
|||||||
Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
|
Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
|
||||||
Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
|
Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
|
||||||
|
|
||||||
Vector3 dir = new Vector3(1, 0, 0) * p * y;
|
Vector3 dir = Vector3.UnitX * p * y;
|
||||||
Vector3 offset = dir * (float)Distance;
|
Vector3 offset = dir * Distance;
|
||||||
|
|
||||||
offset *= rot;
|
offset *= rot;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user