-
Notifications
You must be signed in to change notification settings - Fork 0
Home
All functions except set
create new vectors so that the original vector is not modified. All the functions (except set
which return the modified vector) return the new vector so that operations can be chained easily.
Creates a new vector with components x
, y
and z
. Components defaults to zero.
Creates a new vector from spherical coordinates. theta
is the polar angle (from the upwards y
axis) and phi
the azimut (counting clockwise around y
, starting from x
).
Creates a vector with a random direction and magnitude of length
(defaults to 1).
Allows to print a vector.
Allows to create strings from vector concatenation.
Returns the opposite vector.
Return true if two vectors have their components equals
Return the sum of two vectors component wise. If one argument is a number then this number is added to each component of the vector.
Return the difference of two vectors component wise. If one argument is a number then this number is subtracted to each component of the vector.
Return the product of two vectors component wise. If one argument is a number then each component of the vector is multiplied by this number.
Return the division of two vectors component wise. If one argument is a number then each component of the vector is divided by this number.
Sets the x
,y
and z
components of the vector and return it. If a parameter is nil then the corresponding component is unchanged.
Return a new vector which is a copy of the initial vector.
Returns the magnitude of the vector.
Return the corresponding normalized vector (with magnitude one).
Return a new vector which is scaled to magnitude mag
Returns a new vector which is scaled to magnitude max
if its magnitude if greater than max
.
Return a new vector with the components floored.
Return a new vector with the components rounded to the closest integer.
Return a new vector with components x
, y
, z
offset by a
, b
and c
. If a parameter is nil the corresponding component is unchanged.
Return a new vector with the function f
applied to its components.
Returns the distance between the current vector and b
(as if they were representing points).
Returns the dot product of the current vector and b
.
Returns a vector which is the cross product of the current vector and b
.
Returns a new vector which is the current vector rotated around axis
with angle
.
Returns the unpacked components of the current vector.