Get min and max vectors from CFrame and Size of a Region3

Quick question here. I want to reconstruct the min and max Vector3 values from a Region3 simply from its CFrame and Size properties. I need this as I want to be able to store a Region3ā€™s primitive properties (or at least the numbers associated with its Vector3s). Code or links to useful resources would be much appreciated.

1 Like

I whipped this up real quick, should work for your desires :slight_smile:

local start = Vector3.new(10, 0, 10)
local finish = Vector3.new(30, 10, 30)
local region = Region3.new(start, finish)
local cf = region.CFrame;
local sz = region.Size;

local min = cf * CFrame.new(-sz.X / 2, -sz.Y / 2, -sz.Z / 2)
local max = cf * CFrame.new(sz.X / 2, sz.Y / 2, sz.Z / 2)

print(min.p == start); -- true
print(max.p == finish); -- true

Thanks so much! I will make sure to credit you in this project Iā€™m working on.

1 Like