Vector3

Overview

Vector3 is a data type used to express vector in a three-dimensional space using X, Y, and Z axes. It is used to handle a variety of 3D data such as position, direction, speed, and strength. It is also one of the key elements used by many systems to calculate coordinates and vector within a space or simulating 3D physics.

Constructors

new

Creates and returns a new vector using the passed X, Y, and Z values.

Parameters

Parameter
Description

number x

The value of X coordinate.

number y

The value of Y coordinate.

number z

The value of Z coordinate.

Return

Return
Description

Vector3

The created Vector3.

Code Samples

local Vector = Vector3.new(1, 2, 3)
print(Vector)

Properties

X

number

The value of X coordinate.

Code Samples

Y

number

The value of Y coordinate.

Code Samples

Z

number

The value of Z coordinate.

Code Samples

zero

Vector3

A vector of which axis values are zeroes (0, 0, 0).

Code Samples

one

Vector3

A vector of which axis values are ones (1, 1, 1).

Code Samples

xAxis

Vector3

A Vector3 set to have the value of 1 for X axis and 0 for other axes (1, 0, 0).

Code Samples

yAxis

Vector3

A Vector3 set to have the value of 1 for Y axis and 0 for other axes (0, 1, 0).

Code Samples

zAxis

Vector3

A Vector3 set to have the value of 1 for Z axis and 0 for other axes (0, 0, 1).

Code Samples

Unit

Vector3

A Vector3 of which size is removed and length is 1 while maintaining the original direction.

Code Samples

Magnitude

number

The value representing the size of a Vector3.

Code Samples

Methods

Dot

Returns the dot value between two vectors as a scalar.

Parameters

Vector3 vector

The Vector3 to calculate its dot product.

Return

number

Returns the dot product between two vectors as a scalar.

Code Samples

Cross

Returns the cross product between two vectors as a new vector.

Parameters

Vector3 Parameter for cross product.

The Vector3 to calculate its cross product.

Return

Vector3

The created Vector3.

Code Samples

See also

Coordinate System

Last updated