VectorXf
There are 3 VectorXf types:
Vector2fVector3fVector4f
Creation
Vector2f.new(x, y)
Vector3f.new(x, y, z)
Vector4f.new(x, y, z, w)
Fields
x: number
The X component of the VectorXf
y: number
The Y component of the VectorXf
z: number
The Z component of the VectorXf. Only Vector3f and Vector4f have this field.
w: number
The W component of the VectorXf. Only Vector4f has this field.
Methods
Common to all types
self:dot(other)
Returns the dot product between self and other.
self:length()
Returns the length of self.
self:normalize()
Normalizes self. Nothing is returned.
self:normalized()
Returns the normalization of self.
self:clone()
Returns a copy of self.
Vector2f only
self:to_vec3()
Converts self to a Vector3f (z=0).
self:to_vec4()
Converts self to a Vector4f (z=0, w=0).
Vector3f only
All Vector2f methods, plus:
self:cross(other)
Returns the cross product between self and other.
self:reflect(normal)
Returns the reflection of self over normal.
self:refract(normal, eta)
Returns the refraction of self over normal with the given eta.
self:lerp(other, t)
Returns the linear interpolation between self and other with the given t.
self:to_vec2()
Converts self to a Vector2f.
self:to_vec4()
Converts self to a Vector4f (w=0).
self:to_mat()
Converts self to a Matrix4x4f. Treats self as the forward vector.
self:to_quat()
Converts self to a Quaternion. Treats self as the forward vector.
Vector4f only
All Vector3f methods, plus w field.
Meta-methods
VectorXf + VectorXf
VectorXf addition.
VectorXf - VectorXf
VectorXf subtraction.
VectorXf * scalar
VectorXf scalar multiplication.