예제 #1
0
        private static Range Get1dProjectionOntoAxis(this IIntersectable intersectable, Vector2 axis)
        {
            float min = float.PositiveInfinity, max = float.NegativeInfinity;

            foreach (Vector2 vertex in intersectable.GetVertices())
            {
                float projection = Vector2.Dot(vertex, axis);
                if (projection < min)
                {
                    min = projection;
                }
                if (projection > max)
                {
                    max = projection;
                }
            }

            return(new Range(min, max));
        }