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
v1 = pf.Vector.New()
v1.x = 1
v1.y = 1
v1.z = 1
v2 = pf.Vector(2,2,2)
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:
- Properties
- Static functions
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)
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.