Skip to content

vec3

Fields

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

Example

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

Methods

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

vec3:length( )

Description

Calculates the length of the vector.

Example

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

Returns

number - length of the vector


vec3:dot( )

Description

Calculates the dot product of two vectors.

Arguments

Name Type Description
other vec3 the other vector

Example

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

Returns

number - dot product of the two vectors


vec3:cross( )

Description

Calculates the cross product of two vectors.

Arguments

Name Type Description
other vec3 the other vector

Example

a = vec3( 1, 0, 0 )
b = vec3( 0, 1, 0 )
c = a:cross( b )
utility.println( 'cross: ' .. c.x .. ' ' .. c.y .. ' ' .. c.z )

Returns

vec3 - cross product of the two vectors