-- public methods


function region3:castPoint(point)
	local direction = self.centroid - point;
	return gjk(self.input, {point}, self.support, support.point, direction);
end;

function region3:castPart(part)
	local against = classify(part);
	local direction = self.centroid - against.centroid;
	return gjk(self.input, against.input, self.support, against.support, direction);
end;

function region3:cast(ignore, maxParts)
	local ignore = type(ignore) == "table" and ignore or {ignore};
	local maxParts = maxParts or 1000;
	
	local min, max = {}, {};
	for _, enum in next, {Enum.NormalId.Right, Enum.NormalId.Top, Enum.NormalId.Back} do
		local direction = Vector3.FromNormalId(enum);
		insert(min, self.support(-direction, unpack(self.input)));
		insert(max, self.support(direction, unpack(self.input)));
	end;
	min, max = v3(min[1].x, min[2].y, min[3].z), v3(max[1].x, max[2].y, max[3].z);
	
	local allignedR3 = R3(min, max);
	local parts = game.Workspace:FindPartsInRegion3WithIgnoreList(allignedR3, ignore, maxParts);
	
	-- debug stuff
	--game.Workspace.CurrentCamera:ClearAllChildren();
	--draw.line(min, max, game.Workspace.CurrentCamera);
	
	local inRegion = {};
	for i = 1, #parts do
		local part = parts[i];
		if (self:castPart(part)) then
			insert(inRegion, part);
		end;
	end;
	return inRegion;
end;
