mirror of
https://github.com/ppy/osu
synced 2025-01-11 16:49:39 +00:00
Use MathF
instead of (float)Math
This commit is contained in:
parent
26086ca1ef
commit
ec8810cc2b
@ -84,20 +84,20 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
/// <returns>The rotated vector.</returns>
|
/// <returns>The rotated vector.</returns>
|
||||||
public static Vector2 RotateVectorTowardsVector(Vector2 initial, Vector2 destination, float rotationRatio)
|
public static Vector2 RotateVectorTowardsVector(Vector2 initial, Vector2 destination, float rotationRatio)
|
||||||
{
|
{
|
||||||
var initialAngleRad = Math.Atan2(initial.Y, initial.X);
|
var initialAngleRad = MathF.Atan2(initial.Y, initial.X);
|
||||||
var destAngleRad = Math.Atan2(destination.Y, destination.X);
|
var destAngleRad = MathF.Atan2(destination.Y, destination.X);
|
||||||
|
|
||||||
var diff = destAngleRad - initialAngleRad;
|
var diff = destAngleRad - initialAngleRad;
|
||||||
|
|
||||||
while (diff < -Math.PI) diff += 2 * Math.PI;
|
while (diff < -MathF.PI) diff += 2 * MathF.PI;
|
||||||
|
|
||||||
while (diff > Math.PI) diff -= 2 * Math.PI;
|
while (diff > MathF.PI) diff -= 2 * MathF.PI;
|
||||||
|
|
||||||
var finalAngleRad = initialAngleRad + rotationRatio * diff;
|
var finalAngleRad = initialAngleRad + rotationRatio * diff;
|
||||||
|
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
initial.Length * (float)Math.Cos(finalAngleRad),
|
initial.Length * MathF.Cos(finalAngleRad),
|
||||||
initial.Length * (float)Math.Sin(finalAngleRad)
|
initial.Length * MathF.Sin(finalAngleRad)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user