function Util.makeOrientation(d,C)C=C.unit local G=dot(ux,C)if G>.99999 then return cframe(d,d-uz)elseif G<-0.99999 then return cframe(d,d+uz)else local W=cross(ux,C)local q=1+G local Y=sqrt(W.magnitude^2+q*q)W=W/Y q=q/Y return cframe(d.x,d.y,d.z,W.x,W.y,W.z,q)end end return Util
-- Making a CFrame value from an origin position and unit direction:
function Util.makeOrientation(sourcePos, dir)
	-- Construct CFrame to rotate parts from x-axis alignment (where they are constructed) to
	-- the world orientation of the arc from a quaternion rotation that describes the
	-- rotation of ux-->axis
	dir = dir.unit

	-- Proportionate angle between ux and direction:
	local angleUxAxis = dot(ux, dir)

	if angleUxAxis > 0.99999 then
		return cframe(sourcePos, sourcePos - uz)
	elseif angleUxAxis < -0.99999 then
		return cframe(sourcePos, sourcePos + uz)
	else
		local q = cross(ux, dir)
		local qw = 1 + angleUxAxis
		local qnorm = sqrt(q.magnitude ^ 2 + qw * qw)
		q = q / qnorm
		qw = qw / qnorm
		return cframe(sourcePos.x, sourcePos.y, sourcePos.z, q.x, q.y, q.z, qw)
	end
end

return Util
