function module.create(o,S,T,i,k)local W={Target=Vector3.new();Position=Vector3.new();Velocity=Vector3.new();Mass=S or 5,Force=T or 50;Damping=i or 4,Speed=k or 4}function W.SetBaseValue(o,S)o.Target=S o.Position=S o.Velocity=S end function W.Shove(o,S)local T,i,k=S.X,S.Y,S.Z if T~=T or T==math.huge or T==-math.huge then T=0 end if i~=i or i==math.huge or i==-math.huge then i=0 end if k~=k or k==math.huge or k==-math.huge then k=0 end o.Velocity=o.Velocity+Vector3.new(T,i,k)end function W.Update(o,S)local T=(math.min(S,1)*o.Speed)/ITERATIONS for S=1,ITERATIONS,1 do local i=o.Target-o.Position local k=(i*o.Force)/o.Mass k=k-o.Velocity*o.Damping o.Velocity=o.Velocity+k*T o.Position=o.Position+o.Velocity*T end return o.Position end return W end


function module.create(self, mass, force, damping, speed)

	local spring	= {
		Target		= Vector3.new();
		Position	= Vector3.new();
		Velocity	= Vector3.new();

		Mass		= mass or 5;
		Force		= force or 50;
		Damping		= damping or 4;
		Speed		= speed  or 4;
	}
	
	function spring.SetBaseValue(self, V)
		self.Target = V
		self.Position = V
		self.Velocity = V
	end
	
	function spring.Shove(self, force)
		local x, y, z	= force.X, force.Y, force.Z
		if x ~= x or x == math.huge or x == -math.huge then
			x	= 0
		end
		if y ~= y or y == math.huge or y == -math.huge then
			y	= 0
		end
		if z ~= z or z == math.huge or z == -math.huge then
			z	= 0
		end
		self.Velocity	= self.Velocity + Vector3.new(x, y, z)
	end

	function spring.Update(self, dt)
		local scaledDeltaTime = math.min(dt,1) * self.Speed / ITERATIONS

		for i = 1, ITERATIONS do
			local iterationForce= self.Target - self.Position
			local acceleration	= (iterationForce * self.Force) / self.Mass

			acceleration		= acceleration - self.Velocity * self.Damping

			self.Velocity	= self.Velocity + acceleration * scaledDeltaTime
			self.Position	= self.Position + self.Velocity * scaledDeltaTime
		end

		return self.Position
	end

	return spring
end
