# Vector3

Show Deprecated

The Vector3 data type represents a vector in 3D space, typically usually used as a point in 3D space or the dimensions of a rectangular prism. Vector3 supports basic component-based arithmetic operations (sum, difference, product, and quotient) and these operations can be applied on the left or right hand side to either another Vector3 or a number. It also features methods for common vector operations, such as Cross() and Dot().

Some example usages of Vector3 are the Position, Rotation, and Size of parts, for example:

``````local part = workspace.Part
part.Position = part.Position + Vector3.new(5, 2, 10)  -- Move part by (5, 2, 10)``````

Vector3 is also commonly used when constructing more complex 3D data types such as CFrame. Many of these data types' methods will use a Vector3 within their parameters, such as CFrame:PointToObjectSpace().

## Summary

### Properties

• A Vector3 with a magnitude of zero.

• A Vector3 with a value of 1 on every axis.

• A Vector3 with a value of 1 on the X axis.

• A Vector3 with a value of 1 on the Y axis.

• A Vector3 with a value of 1 on the Z axis.

• The x-coordinate of the Vector3.

• The y-coordinate of the Vector3.

• The z-coordinate of the Vector3.

• The length of the Vector3.

• A normalized copy of the Vector3 - one that has the same direction as the original but a magnitude of 1.

### Methods

• Abs()

Returns a new vector from the absolute values of the original's components.

• Returns a new vector from the ceiling of the original's components.

• Returns a new vector from the floor of the original's components.

• Returns a new vector from the sign (-1, 0, or 1) of the original's components.

• Cross(other : Vector3)

Returns the cross product of the two vectors.

• Angle(other : Vector3,axis : Vector3)

Returns the angle in radians between the two vectors. If you provide an axis, it determines the sign of the angle.

• Dot(other : Vector3)

Returns a scalar dot product of the two vectors.

• FuzzyEq(other : Vector3,epsilon : number):bool

Returns true if the X, Y, and Z components of the other Vector3 are within epsilon units of each corresponding component of this Vector3.

• Lerp(goal : Vector3,alpha : number)

Returns a Vector3 linearly interpolated between this Vector3 and the given goal by the given alpha.

• Max(vector : Vector3)

Returns a Vector3 with each component as the highest among the respective components of both provided Vector3 objects.

• Min(vector : Vector3)

Returns a Vector3 with each component as the lowest among the respective components of both provided Vector3 objects.

Default Value: 0
Default Value: 0
Default Value: 0

axis: Enum.Axis

## Properties

### zero

A Vector3 with a magnitude of zero.

This API member is a constant, and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

``print(Vector3.zero) --> 0, 0, 0``

### one

A Vector3 with a value of 1 on every axis.

This API member is a constant, and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

``print(Vector3.one)  --> 1, 1, 1``

### xAxis

A Vector3 with a value of 1 on the X axis.

This API member is a constant, and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

``print(Vector3.xAxis)  --> 1, 0, 0``

### yAxis

A Vector3 with a value of 1 on the Y axis.

This API member is a constant, and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

``print(Vector3.yAxis)  --> 0, 1, 0``

### zAxis

A Vector3 with a value of 1 on the Z axis.

This API member is a constant, and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

``print(Vector3.zAxis)  --> 0, 0, 1``

### X

The x-coordinate of the Vector3.

### Y

The y-coordinate of the Vector3.

### Z

The z-coordinate of the Vector3.

### Magnitude

The length of the Vector3.

### Unit

A normalized copy of the Vector3 - one that has the same direction as the original but a magnitude of 1.

## Methods

### Abs

Returns a new vector from the absolute values of the original's components. For example, a vector of (-2, 4, -6) returns a vector of (2, 4, 6).

### Ceil

Returns a new vector from the ceiling of the original's components. For example, a vector of (-2.6, 5.1, 8.8) returns a vector of (-2, 6, 9).

### Floor

Returns a new vector from the floor of the original's components. For example, a vector of (-2.6, 5.1, 8.8) returns a vector of (-3, 5, 8).

### Sign

Returns a new vector from the sign (-1, 0, or 1) of the original's components. For example, a vector of (-2.6, 5.1, 0) returns a vector of (-1, 1, 0).

### Cross

Returns the cross product of the two vectors.

other: Vector3

### Angle

Returns the angle in radians between the two vectors. If you provide an axis, it determines the sign of the angle.

#### Parameters

other: Vector3
axis: Vector3
Default Value: nil

### Dot

Returns a scalar dot product of the two vectors.

other: Vector3

### FuzzyEq

Returns true if the X, Y, and Z components of the other Vector3 are within epsilon units of each corresponding component of this Vector3.

#### Parameters

other: Vector3
epsilon: number
Default Value: 0.00001 aka 1e-5

### Lerp

Returns a Vector3 linearly interpolated between this Vector3 and the given goal Vector3 by the fraction alpha.

Note: the alpha value is not limited to the range [0, 1].

goal: Vector3
alpha: number

### Max

Returns a Vector3 with each component as the highest among the respective components of both provided Vector3 objects.

``````local a = Vector3.new(1, 2, 1)
local b = Vector3.new(2, 1, 2)

print(a:Max(b))  --> Vector3.new(2, 2, 2)``````

vector: Vector3

### Min

Returns a Vector3 with each component as the lowest among the respective components of both provided Vector3 objects.

``````local a = Vector3.new(1, 2, 1)
local b = Vector3.new(2, 1, 2)

print(a:Min(b))  --> Vector3.new(1, 1, 1)``````

vector: Vector3