local t=2.718281828459 local o=1 local n=1 local P=0 local b=0*P local d=P local M=b local h=tick()local function I(o,n,P,b,d,M,h)if n==0 then return P elseif o<.99999999 then local I=(1-o*o)^.5 local E=(P-d)+((2*o)/n)*M local u=((o/I)*(P-d)+b/(I*n))+(((2*o)*o-1)/(I*n))*M local H=math.cos((I*n)*h)local x=math.sin((I*n)*h)local W=t^((o*n)*h)return(((H/W)*E+(x/W)*u)+d)+(h-(2*o)/n)*M,(((n*(H*I-o*x))/W)*u-((n*(H*o+I*x))/W)*E)+M elseif o<1.00000001 then local o=(P-d)+(2/n)*M local I=(P-d)+(b+M)/n local E=t^(n*h)return((o+(I*n)*h)/E+d)+(h-2/n)*M,M-(n/E)*(o+(n*h-1)*I)else local I=(o*o-1)^.5 local E=(M-b)/((2*n)*I)local u=(o/n)*M-(d-P)/2 local H=(1-o/I)*u+E local x=(1+o/I)*u-E local W=t^((-(I+o)*n)*h)local X=t^(((I-o)*n)*h)return((H*W+x*X)+d)+(h-(2*o)/n)*M,(((X*(I-o))*n)*x-((W*(o+I))*n)*H)+M end end local function E(t,o,n)return t+n*o,o end local u={}function u.accelerate(u,t)local H=tick()local x,W=I(o,n,P,b,d,M,H-h)local X,m=E(d,M,H-h)P,b=x,W+t d,M=X,m h=H return setmetatable(u)end
--Accelerate module(part of physics module)
local e = 2.718281828459045
local d = 1
local s = 1
local p0 = 0
local v0 = 0 * p0
local p1 = p0
local v1 = v0
local t0 = tick()

local function posvel(d, s, p0, v0, p1, v1, x)
	if s == 0 then
		return p0
	elseif d < 1 - 1e-8 then
		local h = (1 - d * d) ^ 0.5
		local c1 = (p0 - p1 + 2 * d / s * v1)
		local c2 = d / h * (p0 - p1) + v0 / (h * s) + (2 * d * d - 1) / (h * s) * v1
		local co = math.cos(h * s * x)
		local si = math.sin(h * s * x)
		local ex = e ^ (d * s * x)
		return co / ex * c1 + si / ex * c2 + p1 + (x - 2 * d / s) * v1,
			s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1 + v1
	elseif d < 1 + 1e-8 then
		local c1 = p0 - p1 + 2 / s * v1
		local c2 = p0 - p1 + (v0 + v1) / s
		local ex = e ^ (s * x)
		return (c1 + c2 * s * x) / ex + p1 + (x - 2 / s) * v1, v1 - s / ex * (c1 + (s * x - 1) * c2)
	else
		local h = (d * d - 1) ^ 0.5
		local a = (v1 - v0) / (2 * s * h)
		local b = d / s * v1 - (p1 - p0) / 2
		local c1 = (1 - d / h) * b + a
		local c2 = (1 + d / h) * b - a
		local co = e ^ (-(h + d) * s * x)
		local si = e ^ ((h - d) * s * x)
		return c1 * co + c2 * si + p1 + (x - 2 * d / s) * v1, si * (h - d) * s * c2 - co * (d + h) * s * c1 + v1
	end
end

local function targposvel(p1, v1, x)
	return p1 + x * v1, v1
end

local self = {}

function self:accelerate(a)
	local time = tick()
	local p, v = posvel(d, s, p0, v0, p1, v1, time - t0)
	local tp, tv = targposvel(p1, v1, time - t0)
	p0, v0 = p, v + a
	p1, v1 = tp, tv
	t0 = time
	return setmetatable(self)
end
