local k={}k.__index=k function k.new(f,u,Z)local W=setmetatable({},k)W.PointA=f W.PointB=u W.Distance=Z return W end function k.Solve(f,k)local u=f.PointA.Position-f.PointB.Position local Z=u.Magnitude local W=(f.Distance-Z)/Z local w=(u*W)*.5 if not f.PointA.Anchored then f.PointA.Position=f.PointA.Position+w end if not f.PointB.Anchored then f.PointB.Position=f.PointB.Position-w 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
