Region3: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>MrNicNac
New page: ==Region3== A Region3 is a userdata that holds three values inside of it. It holds three Vector3 values, which each hold three more numbers. ==Constructors== {|border="1" cellspa...
 
No edit summary
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Region3==
{{NonStandard|reason=Region3 was added in April 2011.}}
A Region3 is a userdata that holds three values inside of it. It holds three [[Vector3]] values, which each hold three more numbers.


==[[Constructors]]==
A Region3 is used to represent a size and a location in 3D space.


{|border="1" cellspacing="5" style=" -webkit-border-radius: 4px; -moz-border-radius: 4px; height: 100%; background-color: #FFFFFF; border-top: dashed 2px #ff0000; border-left: dashed 2px #ff0000; border-bottom: dashed 2px #aa0000; border-right: dashed 2px #aa0000; margin: 6px; margin-right: 10px; margin-left: 10px; clear: none; padding: 2px;"
[[Image:region3_vis.png|thumb|A representation of a Region3 with its '''<span style="color:magenta">lower</span>''' and '''<span style="color:cyan">upper</span>''' points. The colored arrows represent the orientation of the [[world space]] at (0, 0, 0).]]
A Region3 can be created with the '''Region3.new''' constructor, which receives two [[Vector3]] values:
Region3.new( Vector3.new(1, 1, 1), Vector3.new(9, 9, 9) )
-- a Region3 with a size of (8, 8, 8) and a position at (5, 5, 5)
This constructor can only create a [[bounding box]]. That is, you can't create a rotated Region3, because you can only define two corners of the bounding box. The first argument is the lower corner of the bounding box, while the second argument is the upper corner. Note that this means the X,Y and Z for the second argument should all be larger than the first one. Example :  
 
local start_point = Vector3.new(5, 8, 5)
local end_point = Vector3.new(8, 5, 8)
Region3.new(
    Vector3.new(
        math.min(start_point.X, end_point.X),
        math.min(start_point.Y, end_point.Y),
        math.min(start_point.Z, end_point.Z)
    ),
    Vector3.new(
        math.max(start_point.X, end_point.X),
        math.max(start_point.Y, end_point.Y),
        math.max(start_point.Z, end_point.Z)
    )
)
 
The above example returns a Region3 with a size of (3, 3, 3) and a position of (5, 5, 5).
 
When printed, the Region3's [[CFrame]] and Size are displayed:
5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3
 
==Constructors==
 
{| class="wikitable"
! Constructor !! Description
! Constructor !! Description
|-
|-
| Region3.new('''Vector3''', '''Vector3''', '''Vector3''') || Creates a new Region3 out of three Vector3 values.
| Region3.new('''Vector3''', '''Vector3''') || Creates a new Region3 out of two Vector3 values.
|}
|}
==Properties==
All the of a properties Region3 userdata are read-only and cannot be set or edited directly. You must create a new Region3 using Region3.new() to make the properties change.
{| class="wikitable"
!Property !! Type !! Description
|-
| Region3.CFrame || [[CFrame]] || The center location and rotation of the the Region3
|-
| Region3.Size || [[Vector3]] || The 3D size of the Region3
|}
==See Also==
*[[FindPartsInRegion3]]

Latest revision as of 19:51, 18 November 2023

Ouch!
The following article, Region3, mentions a feature exclusive to certain versions of the client.
Specifically: Region3 was added in April 2011.


A Region3 is used to represent a size and a location in 3D space.

A representation of a Region3 with its lower and upper points. The colored arrows represent the orientation of the world space at (0, 0, 0).

A Region3 can be created with the Region3.new constructor, which receives two Vector3 values:

Region3.new( Vector3.new(1, 1, 1), Vector3.new(9, 9, 9) )
-- a Region3 with a size of (8, 8, 8) and a position at (5, 5, 5)

This constructor can only create a bounding box. That is, you can't create a rotated Region3, because you can only define two corners of the bounding box. The first argument is the lower corner of the bounding box, while the second argument is the upper corner. Note that this means the X,Y and Z for the second argument should all be larger than the first one. Example :

local start_point = Vector3.new(5, 8, 5)
local end_point = Vector3.new(8, 5, 8)
Region3.new(
    Vector3.new(
        math.min(start_point.X, end_point.X),
        math.min(start_point.Y, end_point.Y),
        math.min(start_point.Z, end_point.Z)
    ),
    Vector3.new(
        math.max(start_point.X, end_point.X),
        math.max(start_point.Y, end_point.Y),
        math.max(start_point.Z, end_point.Z)
    )
)

The above example returns a Region3 with a size of (3, 3, 3) and a position of (5, 5, 5).

When printed, the Region3's CFrame and Size are displayed:

5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3

Constructors

Constructor Description
Region3.new(Vector3, Vector3) Creates a new Region3 out of two Vector3 values.

Properties

All the of a properties Region3 userdata are read-only and cannot be set or edited directly. You must create a new Region3 using Region3.new() to make the properties change.

Property Type Description
Region3.CFrame CFrame The center location and rotation of the the Region3
Region3.Size Vector3 The 3D size of the Region3

See Also