public short GetPitch(SplineVertex other) { float differenceX = Position.X - other.Position.X; float differenceZ = Position.Z - other.Position.Z; double adjacent = Math.Sqrt(Math.Pow(differenceX, 2) + Math.Pow(differenceZ, 2)); // Use Pythagoras to get angle between hypotenuse and Y. float opposite = Position.Y - other.Position.Y; // Calculate angle. double tan = opposite / adjacent; double angle = Math.Tanh(tan); // (angle / (2 * Math.PI)) gets a decimal e.g. 0.20 where 1 is 100% double decimalAngle = (angle / (2 * Math.PI)); return((short)(decimalAngle * short.MaxValue * -1)); // Pitch direction in Heroes is opposite. }
public float GetDistance(SplineVertex other) { return(Vector3.Distance(Position, other.Position)); }