revival/game/Assets/Scripts/Util/MathsExtensions.cs

22 lines
506 B
C#
Raw Normal View History

2021-02-15 19:09:32 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Extensions
{
public static class MathsExtensions
{
public static Vector2 Rotate( this Vector2 v, float angle )
{
float sa = Mathf.Sin( angle );
float ca = Mathf.Cos( angle );
return new Vector2
{
x = ca * v.x - sa * v.y,
y = sa * v.x + ca * v.y
};
}
}
}