local p={}p.__index=p function p.new(f,s,b)local m=setmetatable({},p)m.PointA=f m.PointB=s m.Distance=b return m end function p.Solve(f,p)local s=f.PointA.Position-f.PointB.Position local b=s.Magnitude local m=(f.Distance-b)/b local T=(s*m)*.5 if not f.PointA.Anchored then f.PointA.Position=f.PointA.Position+T end if not f.PointB.Anchored then f.PointB.Position=f.PointB.Position-T end end


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
