--


local Constraint = {}
Constraint.__index = Constraint

function Constraint.new(pointA, pointB, distance)
	local self = setmetatable({}, Constraint)
	
	self.PointA = pointA
	self.PointB = pointB
	
	self.Distance = distance
	
	return self
end

function Constraint:Solve(dt)
	local difference = (self.PointA.Position - self.PointB.Position)
	local currentDistance = difference.Magnitude
	local percent = (self.Distance - currentDistance) / currentDistance
	
	local translation = difference*percent * 0.5
	
	if (not self.PointA.Anchored) then
		self.PointA.Position = self.PointA.Position + translation
	end
	if (not self.PointB.Anchored) then
		self.PointB.Position = self.PointB.Position - translation
	end
end
