Skip to content

vec2

Fields

Name Type Description Access rights
x number x coordinate read/write
y number y coordinate read/write

Example

vector = vec2( 2, 3 ) -- or vector = vec2( )
utility.println( 'x:' .. vector.x .. ' y:' .. vector.y )

Methods

Method Description Returns
length( ) calculates the length number
dot( other ) calculates the dot product number

vec2:length( )

Description

Calculates the length of the vector.

Example

vector = vec2( 3, 4 )
utility.println( 'length: ' .. vector:length( ) )

Returns

number - length of the vector


vec2:dot( )

Description

Calculates the dot product of two vectors.

Arguments

Name Type Description
other vec2 the other vector

Example

a = vec2( 1, 0 )
b = vec2( 0, 1 )
utility.println( 'dot: ' .. a:dot( b ) )

Returns

number - dot product of the two vectors