vector
This type is a common 3D vector (x, y, z).
This type supports operations, such as +
, -
, /
, *
and ==
.
x
Type: float
X coordinate.
y
Type: float
Y coordinate.
z
Type: float
Z coordinate.
__call
Constructs a vector.
Arguments
1. Default vector (0, 0, 0).
None.
2. Single value.
Name
Type
Description
value
float
X and Y coordinates.
3. XYZ values.
Name
Type
Description
x
float
X coordinate.
y
float
Y coordinate.
z
float
Z coordinate.
Returns
Type
Description
vector
Vector.
Example
is_zero
Returns true
if this vector is within tolerance range.
Arguments
Name
Type
Description
tolerance
float
Max allowed tolerance. Defaults to 0.01
.
Returns
Type
Description
bool
true
if ranges between -tolerance
and tolerance
.
Example
dist
Returns distance to another vector.
Arguments
Name
Type
Description
other
vector
Vector to calculate distance against.
Returns
Type
Description
float
Distance to other vector.
Example
dist_sqr
Returns squared distance to another vector.
This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.
Arguments
Name
Type
Description
other
vector
Vector to calculate distance against.
Returns
Type
Description
float
Squared distance to other vector.
Example
dist_2d
Returns 2D (only x
and y
values) distance to another vector.
Arguments
Name
Type
Description
other
vector
Vector to calculate distance against.
Returns
Type
Description
float
Distance to other vector.
Example
dist_2d_sqr
Returns squared 2D (only x
and y
values) distance to another vector.
This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.
Arguments
Name
Type
Description
other
vector
Vector to calculate distance against.
Returns
Type
Description
float
Squared distance to other vector.
Example
cross
Returns a cross product to another vector.
Arguments
Name
Type
Description
other
vector
Vector to calculate cross product against.
Returns
Type
Description
vector
Cross product.
Example
is_valid
Returns true
if all values in this vector are finite.
Arguments
None.
Returns
Type
Description
bool
true
if values are finite.
Example
length
Returns length of this vector.
Arguments
None.
Returns
Type
Description
float
Length of this vector.
Example
length_sqr
Returns squared length of this vector.
This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.
Arguments
None.
Returns
Type
Description
float
Length of this vector.
Example
length_2d
Returns 2D length of this vector.
Arguments
None.
Returns
Type
Description
float
Length of this vector.
Example
length_2d_sqr
Returns squared 2D length of this vector.
This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.
Arguments
None.
Returns
Type
Description
float
Length of this vector.
Example
dot
Returns dot product of 2 vectors.
Arguments
Name
Type
Description
other
vector
Vector to calculate dot product against.
Returns
Type
Description
float
Dot product.
Example
Last updated