public void V2_FromPolar()
        {
            Vector2 a = Vector2X.FromPolar(1, MathF.PI * 0.5f);
            Vector2 b = Vector2X.FromPolar(1, MathF.PI * 1.0f);
            Vector2 c = Vector2X.FromPolar(1, MathF.PI * 1.5f);
            Vector2 d = Vector2X.FromPolar(1, MathF.PI * 2.0f);

            Vector2X.Equals(a, Vector2.UnitY, .000001f);
            Vector2X.Equals(b, Vector2.UnitX, .000001f);
            Vector2X.Equals(c, Vector2.UnitY, .000001f);
            Vector2X.Equals(d, Vector2.UnitX, .000001f);
        }
Exemple #2
0
        private static Polygon RegularShape(float angle, int pointCount, float size)
        {
            float step = 2 * (float)Math.PI / pointCount;

            Polygon result = new Polygon();

            for (int i = 0; i < pointCount; i++)
            {
                result.Add(Vector2X.FromPolar(size, angle));
                angle += step;
            }

            return(result);
        }
Exemple #3
0
 /// <summary>
 /// Gets the next random unit vector.
 /// </summary>
 /// <param name="random"></param>
 /// <param name=""></param>
 /// <returns></returns>
 public static Vector2 NextUnitVector(this IRandom random) => Vector2X.FromPolar(1, random.NextAngle());