Created
November 20, 2018 21:16
-
-
Save jringrose/5673c34a8c1c2d46d441b6050849331c to your computer and use it in GitHub Desktop.
Revisions
-
jringrose created this gist
Nov 20, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ using System; using UnityEngine; public static class Extensions_Math { // ... public static float VectorToRad(this Vector2 thisVec){ return Mathf.Atan2(thisVec.y, thisVec.x); } public static Vector2 RadToVector(this float thisFloat){ return new Vector2(Mathf.Cos(thisFloat), Mathf.Sin(thisFloat)); } public static float VectorToDeg(this Vector2 thisVec){ return Mathf.Atan2(thisVec.y, thisVec.x) * Mathf.Rad2Deg; } public static Vector2 DegToVector(this float thisFloat){ return new Vector2(Mathf.Cos(thisFloat * Mathf.Deg2Rad), Mathf.Sin(thisFloat * Mathf.Deg2Rad)); } // ... }