local function k(k,l,E)local D,v=k:Dot(l),k:Cross(l)if D<-0.99999 then return CFrame.fromAxisAngle(E,math.pi)end return CFrame.new(0,0,0,v.x,v.y,v.z,1+D)end local function l(k,l)local E,D=k:ToAxisAngle()local v,g=math.cos(D/2),math.sin(D/2)*E local o=g:Dot(l)*l local m=CFrame.new(0,0,0,o.x,o.y,o.z,v)local s,b=m:ToAxisAngle()return math.sign(g:Dot(l))*b end


local function getRotationBetween(u, v, axis)
	local dot, uxv = u:Dot(v), u:Cross(v)
	if (dot < -0.99999) then return CFrame.fromAxisAngle(axis, math.pi) end
	return CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)
end

local function twistAngle(cf, direction)
    local axis, theta = cf:ToAxisAngle()
    local w, v = math.cos(theta/2),  math.sin(theta/2)*axis
	local proj = v:Dot(direction)*direction
    local twist = CFrame.new(0, 0, 0, proj.x, proj.y, proj.z, w)
    local nAxis, nTheta = twist:ToAxisAngle()
	return math.sign(v:Dot(direction))*nTheta
end
