Vector2

In BrickVerse, the Vector2 datatype is often used in working with GUI elements and 2D mouse positions.

Constructors

Vector2.new ( number x, number y )

Returns a Vector2 from the given x and y components.

Properties

Vector2 Vector2.zero

A Vector2 with a magnitude of zero.

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

print(Vector2.zero) --> 0, 0

Vector2 Vector2.one

A Vector2 with a value of 1 on every axis.

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

print(Vector2.one) --> 1, 1

Vector2 Vector2.xAxis

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

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

print(Vector2.xAxis) --> 1, 0

Vector2 Vector2.yAxis

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

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

print(Vector2.yAxis) --> 0, 1

number Vector2.X

The x-coordinate of the Vector2.

number Vector2.Y

The y-coordinate of the Vector2.

number Vector2.Magnitude

The length of the vector.

Vector2 Vector2.Unit

A normalized copy of the vector.

Functions

number Vector2:Cross ( Vector2 other )

Returns the cross product of the two vectors.

number Vector2:Dot ( Vector2 v )

Returns a scalar dot product of the two vectors.

Vector2 Vector2:Lerp ( Vector2 v, number alpha )

Returns a Vector2 linearly interpolated between this Vector2 and v by the fraction alpha

Vector2 Vector2:Max ( Tuple others... )

Returns a Vector2 where each component is the highest among the respective components of the provided Vector2s.

local a = Vector2.new(1, 2)
local b = Vector2.new(2, 1) 
print(a:Max(b)) -- Vector2.new(2, 2)

Vector2 Vector2:Min ( Tuple others... )

Returns a Vector2 where each component is the lowest among the respective components of the provided Vector2s.

local a = Vector2.new(1, 2)local b = Vector2.new(2, 1) 
print(a:Min(b)) -- Vector2.new(1, 1)

Last updated