Vector

A Cartesian vector (direction). This object lives in the Lua session only. Vectors are defined by numbers and cannot be defined with expressions. Mathematical operations can be done on vectors.

Example

    -- Create a default 'Vector' at (0,0,0)

v1 = pf.Vector.New()

    -- Assign values to each component of the vector

v1.x = 1
v1.y = 1
v1.z = 1

    -- Create a 'Vector' with number values

v2 = pf.Vector(2,2,2)

    -- Some of the valid operators for 'Vector'

v3 = 2 * v1
v4 = v2 * 2
v5 = v2 / 2
v6 = -v2
v7 = v1 + v2
v8 = v1 - v2
if (v1 ~= v2) then
    print(v1.." is not equal to "..v2)
end

Usage locations

The Vector object can be accessed from the following locations:

Property List

Type
The object type string. (Read only string)
X
The x component of the vector. (Read/Write number)
Y
The y component of the vector. (Read/Write number)
Z
The z component of the vector. (Read/Write number)

Constructor Function List

New (x number, y number, z number)
Creates a new vector. (Returns a Vector object.)
New ()
Creates a new Vector. (Returns a Vector object.)

Index List

[number]
Index a component of the vector. (Read number)
[number]
Index a component of the vector. (Write number)

Property Details

Type
The object type string.
Type
string
Access
Read only
X
The x component of the vector.
Type
number
Access
Read/Write
Y
The y component of the vector.
Type
number
Access
Read/Write
Z
The z component of the vector.
Type
number
Access
Read/Write

Static Function Details

New (x number, y number, z number)
Creates a new vector.
Input Parameters
x(number)
The x component.
y(number)
The y component.
z(number)
The z component.
Return
Vector
The new vector.
New ()
Creates a new Vector.
Return
Vector
The new vector.