PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

Vector3int16

Vector3int16

Not to be confused with datatype/Vector3, which is more commonly used in the Roblox API.

Vector3int16 describes a vector in 3D space using a signed 16-bit integer for its components. It is similar to datatype/Vector3 in that it allows for the same arithmetic operations; however it lacks commonly used vector functions. It is used in constructing Region3int16, which is relevant in some Terrain operations.

For each component:

  • The lower bound is -215, or -32,768
  • The upper bound is 215 − 1, or 32,767

Conversion to Vector3

Converting a Vector3int16 to a Vector3 can be done by passing its components to Vector3.new:

local function ConvertVector3int16ToVector3(vector16)
	return Vector3.new(vector16.X, vector16.Y, vector16.Z)
end

Don’t pass a Vector3int16 to Vector3.new: The Vector3.new constructor interprets a Vector3int16 as a 0 (zero) within its parameters without producing an error. This can lead to silent logic errors if you’re doing something like this:

Vector3.new(Vector3int16.new(1, 2, 3)) --> Vector3.new(0, 0, 0)

In order to properly convert to Vector3, you must construct it component-wise as above.

Constructors

Vector3int16.new ( number x, number y, number z )

Creates a new Vector3int16 given the x, y and z components. Non-integer components are rounded down.

The components must fall within the range [-215, 215). If outside this range, integer overflow may occur. For example, providing 32,768 (equal to 215) as a component overflows the 16-bit integer, and so the component will be -32,768 (equal to -215) instead.

Properties

integer Vector3int16.X

The x-coordinate, also accessible in its lower-case variant.

integer Vector3int16.Y

The y-coordinate, also accessible in its lower-case variant.

integer Vector3int16.Z

The z-coordinate, also accessible in its lower-case variant.

Math Operations

Vector3int16 Vector3int16 + Vector3int16

Returns a Vector3int16 whose components are the sum of the operands’ respective components.
Equivalent to: Vector3int16.new(lhs.X + rhs.X, lhs.Y + rhs.Y, lhs.Z + rhs.Z)

Be mindful of bounds with regards to the signed 16-bit integers used to store the components (described above).

Vector3int16 Vector3int16 - Vector3int16

Returns a Vector3int16 whose components are the difference of the operands’ respective components.
Equivalent to: Vector3int16.new(lhs.X - rhs.X, lhs.Y - rhs.Y, lhs.Z - rhs.Z)

Be mindful of bounds with regards to the signed 16-bit integers used to store the components (described above).

Vector3int16 Vector3int16 * Vector3int16

Returns a Vector3int16 whose components are the product of the operands’ respective components.
Equivalent to: Vector3int16.new(lhs.X * rhs.X, lhs.Y * rhs.Y, lhs.Z * rhs.Z)

Be mindful of bounds with regards to the signed 16-bit integers used to store the components (described above).

Vector3int16 Vector3int16 * number

Returns a Vector3int16 whose components are the product of the Vector3int16’s respective components and the number (factor). This operation is commutative.
Equivalent to: Vector3int16.new(lhs.X * factor, lhs.Y * factor, lhs.Z * factor)

Be mindful of bounds with regards to the signed 16-bit integers used to store the components (described above).

Vector3int16 Vector3int16 / Vector3int16

Returns a Vector3int16 whose components are the quotient of the operands’ respective components.
Equivalent to: Vector3int16.new(lhs.X / rhs.X, lhs.Y / rhs.Y, lhs.Z / rhs.Z)

Be mindful that the signed 16-bit integers used to store the components cannot store fractional portions of the quotient. The results of the division will always be rounded toward zero.

Vector3int16 Vector3int16 / number

Returns a Vector3int16 whose components are the quotient of the Vector3int16’s respective components and the number (divisor).
Equivalent to: Vector3int16.new(lhs.X / divisor, lhs.Y / divisor, lhs.Z / divisor)

Be mindful that the signed 16-bit integers used to store the components cannot store fractional portions of the quotient. The results of the division will always be rounded toward zero.