local H={}function H.PointCloud(H,i)local X,u=H[1],H[1]:Dot(i)for E=2,#H,1 do local B=H[E]:Dot(i)if B>u then X=H[E]u=B end end return X end function H.Cylinder(H,i)local X,u=unpack(H)i=X:VectorToObjectSpace(i)local E=math.min(u.y,u.z)local B,Y=i:Dot(RIGHT),Vector3.new(u.x,0,0)local N,A,I if B==0 then I=i.Unit*E else Y=B>0 and Y or-Y N,A=rayPlane(ZERO,i,Y,RIGHT)I=Y+(N-Y).Unit*E end return X:PointToWorldSpace(I)end function H.Ellipsoid(H,i)local X,u=unpack(H)return X:PointToWorldSpace(u*(u*X:VectorToObjectSpace(i)).Unit)end return H
--

local Supports = {}

function Supports.PointCloud(set, direction)
	local max, maxDot = set[1], set[1]:Dot(direction)
	for i = 2, #set do
		local dot = set[i]:Dot(direction)
		if dot > maxDot then
			max = set[i]
			maxDot = dot
		end
	end
	return max
end

function Supports.Cylinder(set, direction)
	local cf, size2 = unpack(set)
	direction = cf:VectorToObjectSpace(direction)
	local radius = math.min(size2.y, size2.z)
	local dotT, cPoint = direction:Dot(RIGHT), Vector3.new(size2.x, 0, 0)
	local h, t, final

	if dotT == 0 then
		final = direction.Unit * radius
	else
		cPoint = dotT > 0 and cPoint or -cPoint
		h, t = rayPlane(ZERO, direction, cPoint, RIGHT)
		final = cPoint + (h - cPoint).Unit * radius
	end

	return cf:PointToWorldSpace(final)
end

function Supports.Ellipsoid(set, direction)
	local cf, size2 = unpack(set)
	return cf:PointToWorldSpace(size2 * (size2 * cf:VectorToObjectSpace(direction)).Unit)
end

return Supports
