function SPRING.create(n,T,Y,F)local v={Target=Vector3.new(),Position=Vector3.new();Velocity=Vector3.new();Time=0,Mass=n or 5;Force=T or 50,Damping=Y or 4,Speed=F or 4}return setmetatable(v,Meta)end function SPRING.shove(T,n)local Y,F,v=n.X,n.Y,n.Z if Y==math.huge or Y==-math.huge then Y=0 end if F==math.huge or F==-math.huge then F=0 end if v==math.huge or v==-math.huge then v=0 end T.Velocity+=Vector3.new(Y,F,v)end function SPRING.update(T,n)local Y=math.min(T.Time+n*T.Speed,FixedRate*MaxSkips)for n=1,math.floor(Y/FixedRate)*ITERATIONS,1 do local F=T.Target-T.Position local v=(F*T.Force)/T.Mass v-=T.Velocity*T.Damping T.Velocity+=v*iterdt T.Position+=T.Velocity*iterdt Y-=iterdt end T.Time=Y if T.Position.Magnitude>1e-05 then return T.Position end return Vector3.zero end


function SPRING.create(mass, force, damping, speed)
	local spring	= {
		Target		= Vector3.new();
		Position	= Vector3.new();
		Velocity	= Vector3.new();
		Time 		= 0;

		Mass		= mass or 5;
		Force		= force or 50;
		Damping		= damping or 4;
		Speed		= speed  or 4;
	}

	return setmetatable(spring, Meta)
end

function SPRING:shove(force)
	local x, y, z	= force.X, force.Y, force.Z
	if x == math.huge or x == -math.huge then
		x	= 0
	end
	if y == math.huge or y == -math.huge then
		y	= 0
	end
	if z == math.huge or z == -math.huge then
		z	= 0
	end
	self.Velocity	+= Vector3.new(x, y, z)
end

function SPRING:update(dt)
	local Time = math.min(self.Time + dt * self.Speed, FixedRate * MaxSkips)
	
	for i = 1, math.floor(Time / FixedRate) * ITERATIONS do
		local iterationForce = self.Target - self.Position
		local acceleration	 = (iterationForce * self.Force) / self.Mass

		acceleration	-= self.Velocity * self.Damping

		self.Velocity	+= acceleration * iterdt
		self.Position	+= self.Velocity * iterdt
		Time -= iterdt
	end
	
	self.Time = Time
	if self.Position.Magnitude > .00001 then
		return self.Position
	end
	return Vector3.zero
end
