Region3: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>NXTBoy
The example made no sense. @SDuke: Can you confirm that the coordinates of the second point must be larger?
>JulienDethurens
→‎Constructors: Changed uglytable to wikitable.
Line 27: Line 27:
  5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3
  5, 5, 5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 3, 3, 3


==[[Constructors]]==
==Constructors==


{|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;"
{| class="wikitable"
! Constructor !! Description
! Constructor !! Description
|-
|-

Revision as of 01:47, 25 March 2012

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