forked from MoonsideGames/MoonWorks
add Vector2.Rotate methods
parent
9c8ec7ad5a
commit
9cd6e6cc7b
|
@ -674,6 +674,19 @@ namespace MoonWorks.Math.Fixed
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a Vector2 by an angle.
|
||||
/// </summary>
|
||||
/// <param name="vector">The vector to rotate.</param>
|
||||
/// <param name="angle">The angle in radians.</param>
|
||||
public static Vector2 Rotate(Vector2 vector, Fix64 angle)
|
||||
{
|
||||
return new Vector2(
|
||||
vector.X * Fix64.Cos(angle) - vector.Y * Fix64.Sin(angle),
|
||||
vector.X * Fix64.Sin(angle) + vector.Y * Fix64.Cos(angle)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Static Operators
|
||||
|
|
|
@ -1088,6 +1088,19 @@ namespace MoonWorks.Math.Float
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a Vector2 by an angle.
|
||||
/// </summary>
|
||||
/// <param name="vector">The vector to rotate.</param>
|
||||
/// <param name="angle">The angle in radians.</param>
|
||||
public static Vector2 Rotate(Vector2 vector, float angle)
|
||||
{
|
||||
return new Vector2(
|
||||
vector.X * (float) System.Math.Cos(angle) - vector.Y * (float) System.Math.Sin(angle),
|
||||
vector.X * (float) System.Math.Sin(angle) + vector.Y * (float) System.Math.Cos(angle)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Static Operators
|
||||
|
|
Loading…
Reference in New Issue