slimecing

a fighting game featuring slimes and swords
Log | Files | Refs | README

Ellipse.cs (883B)


      1 using UnityEngine;
      2 
      3 namespace Slimecing.Dependency
      4 {
      5     public class Ellipse
      6     {
      7         private readonly float _xAxis;
      8         private readonly float _yAxis;
      9 
     10         public Ellipse(float xAxis, float yAxis)
     11         {
     12             _xAxis = xAxis;
     13             _yAxis = yAxis;
     14         }
     15 
     16         public Vector2 EvaluateEllipse(float prog)
     17         {
     18             float angle = Mathf.Deg2Rad * 360f * prog;
     19             float x = Mathf.Sin(angle) * _xAxis;
     20             float y = Mathf.Cos(angle) * _yAxis;
     21             
     22             return new Vector2(x, y);
     23         }
     24         
     25         public Vector2 EvaluateEllipse(float prog, float xAxis, float yAxis)
     26         {
     27             float angle = Mathf.Deg2Rad * 360f * prog;
     28             float x = Mathf.Sin(angle) * xAxis;
     29             float y = Mathf.Cos(angle) * yAxis;
     30             
     31             return new Vector2(x, y);
     32         }
     33     }
     34 }