local function P(P,p)return{P:PointToWorldSpace(Vector3.new(-p.x,p.y,p.z)),P:PointToWorldSpace(Vector3.new(-p.x,-p.y,p.z));P:PointToWorldSpace(Vector3.new(-p.x,-p.y,-p.z));P:PointToWorldSpace(Vector3.new(p.x,-p.y,-p.z));P:PointToWorldSpace(Vector3.new(p.x,p.y,-p.z));P:PointToWorldSpace(Vector3.new(p.x,p.y,p.z));P:PointToWorldSpace(Vector3.new(p.x,-p.y,p.z)),P:PointToWorldSpace(Vector3.new(-p.x,p.y,-p.z))}end local function p(P)local p,W,u={},{},{}for Y=1,#P,1 do p[Y],W[Y],u[Y]=P[Y].x,P[Y].y,P[Y].z end local Y=Vector3.new(math.min(unpack(p)),math.min(unpack(W)),math.min(unpack(u)))local f=Vector3.new(math.max(unpack(p)),math.max(unpack(W)),math.max(unpack(u)))return Y,f end
-- Private functions

local function getCorners(cf, s2)
	return {
		cf:PointToWorldSpace(Vector3.new(-s2.x, s2.y, s2.z)),
		cf:PointToWorldSpace(Vector3.new(-s2.x, -s2.y, s2.z)),
		cf:PointToWorldSpace(Vector3.new(-s2.x, -s2.y, -s2.z)),
		cf:PointToWorldSpace(Vector3.new(s2.x, -s2.y, -s2.z)),
		cf:PointToWorldSpace(Vector3.new(s2.x, s2.y, -s2.z)),
		cf:PointToWorldSpace(Vector3.new(s2.x, s2.y, s2.z)),
		cf:PointToWorldSpace(Vector3.new(s2.x, -s2.y, s2.z)),
		cf:PointToWorldSpace(Vector3.new(-s2.x, s2.y, -s2.z)),
	}
end

local function worldBoundingBox(set)
	local x, y, z = {}, {}, {}
	for i = 1, #set do
		x[i], y[i], z[i] = set[i].x, set[i].y, set[i].z
	end
	local min = Vector3.new(math.min(unpack(x)), math.min(unpack(y)), math.min(unpack(z)))
	local max = Vector3.new(math.max(unpack(x)), math.max(unpack(y)), math.max(unpack(z)))
	return min, max
end
