return function(g,C,Q,D)local q=-D local S,W,z=g.x,g.y,g.z local X,t=C.x-S,C.z-z local R=X*X+t*t local L=C.y-W if R>0 then local g=Q*Q local C=R/(2*(R+L*L))local D=q*L+g local S=g*((2*q)*L+g)-(q*q)*R if S>0 then local Q=S^.5 local W=C*(D+Q)local z=C*(D-Q)local x,v,s=R^.5,W^.5,z^.5 local n,p,J=(X/x)*v,(g-W)^.5,(t/x)*v local f,e,b=(X/x)*s,(g-z)^.5,(t/x)*s local c=Vector3.new(n,L>(q*R)/(2*g)and p or-p,J)local r=Vector3.new(f,e,b)return c,r else return nil,nil,(Vector3.new(X,R^.5,t)).unit*Q end else local g=Vector3.new(0,Q*(L>0 and 1 or L<0 and-1 or 0),0)return g,g end end
--- Utility function for estimating low and high arcs of projectiles. Solves for bullet
-- drop given

--- Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity
-- @tparam Vector3 origin Origin the the bullet
-- @tparam Vector3 target Target for the bullet
-- @tparam number initialVelocity Magnitude of the initial velocity
-- @tparam number gravityForce Force of the gravity
-- @treturn[opt] vector3 lowTrajectory Initial velocity for a low trajectory arc
-- @treturn[opt] vector3 highTrajectory Initial velocity for a high trajectory arc
-- @treturn[opt] vector3 fallbackTrajectory Trajectory directly at target as afallback
return function(origin, target, initialVelocity, gravityForce)
	local g = -gravityForce
	local ox,oy,oz=origin.x,origin.y,origin.z
	local rx,rz=target.x-ox,target.z-oz
	local tx2=rx*rx+rz*rz
	local ty=target.y-oy
	if tx2>0 then
		local v2=initialVelocity*initialVelocity

		local c0=tx2/(2*(tx2+ty*ty))
		local c1=g*ty+v2
		local c22=v2*(2*g*ty+v2)-g*g*tx2
		if c22>0 then
			local c2=c22^0.5
			local t0x2=c0*(c1+c2)
			local t1x2=c0*(c1-c2)

			local tx,t0x,t1x=tx2^0.5,t0x2^0.5,t1x2^0.5

			local v0x,v0y,v0z=rx/tx*t0x,(v2-t0x2)^0.5,rz/tx*t0x
			local v1x,v1y,v1z=rx/tx*t1x,(v2-t1x2)^0.5,rz/tx*t1x

			local v0=Vector3.new(v0x,ty>g*tx2/(2*v2) and v0y or -v0y,v0z)
			local v1=Vector3.new(v1x,v1y,v1z)

			return v0,v1
		else
			return nil, nil, Vector3.new(rx, (tx2^0.5), rz).unit * initialVelocity
		end
	else
		local v=Vector3.new(0,initialVelocity*(ty>0 and 1 or ty<0 and -1 or 0),0)
		return v,v
	end
end