Danmaku_no_Kyojin.Collisions.CollisionConvexPolygon.ComputeAxes C# (CSharp) Method

ComputeAxes() private method

private ComputeAxes ( ) : void
return void
        private void ComputeAxes()
        {
            if (Vertices.Count == 0)
                return;

            // We start by deleting former axis
            _axes.Clear();

            Vector2 previousPosition = GetWorldPosition(Vertices[0]);

            for (int i = 1; i <= Vertices.Count; i++)
            {
                Vector2 position = GetWorldPosition(i == Vertices.Count ? Vertices[0] : Vertices[i]);

                Vector2 edge = position - previousPosition;
                var normal = new Vector2(edge.Y, -edge.X);

                // We want to avoid to have parallel axes because projection would give us the same result
                if (!_axes.Contains(normal) && !_axes.Contains(-normal))
                    _axes.Add(normal);

                previousPosition = position;
            }
        }