Project290.Physics.Collision.DistanceProxy.GetSupportVertex C# (CSharp) Method

GetSupportVertex() public method

Get the supporting vertex in the given direction.
public GetSupportVertex ( Vector2 direction ) : Vector2
direction Vector2 The direction.
return Vector2
        public Vector2 GetSupportVertex(Vector2 direction)
        {
            int bestIndex = 0;
            float bestValue = Vector2.Dot(Vertices[0], direction);
            for (int i = 1; i < Vertices.Count; ++i)
            {
                float value = Vector2.Dot(Vertices[i], direction);
                if (value > bestValue)
                {
                    bestIndex = i;
                    bestValue = value;
                }
            }

            return Vertices[bestIndex];
        }