using MoonWorks.Math.Fixed;

namespace MoonWorks.Collision.Fixed
{
	/// <summary>
	/// A Minkowski difference between two shapes.
	/// </summary>
	public struct MinkowskiDifference<T, U> where T : IShape2D where U : IShape2D
	{
		private T ShapeA { get; }
		private Transform2D TransformA { get; }
		private U ShapeB { get; }
		private Transform2D TransformB { get; }

		public MinkowskiDifference(T shapeA, Transform2D transformA, U shapeB, Transform2D transformB)
		{
			ShapeA = shapeA;
			TransformA = transformA;
			ShapeB = shapeB;
			TransformB = transformB;
		}

		public Vector2 Support(Vector2 direction)
		{
			return ShapeA.Support(direction, TransformA) - ShapeB.Support(-direction, TransformB);
		}
	}
}
