A 4D vector using floating-point coordinates.
A 4-element structure that can be used to represent 4D coordinates or any other quadruplet of numeric values.
It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike float which is always 64-bit. If double precision is needed, compile the engine with the option precision=double.
See Vector4i for its integer counterpart.
Note: In a boolean context, a Vector4 will evaluate to false if it's equal to Vector4(0, 0, 0, 0). Otherwise, a Vector4 will always evaluate to true.
Returns a new vector with all components clamped between the components of min and max, by running clamp() on each component.
Returns a new vector with all components clamped between min and max, by running clamp() on each component.
Performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
Performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
It can perform smoother interpolation than cubic_interpolate() by the time values.
Returns the normalized vector pointing from this vector to to. This is equivalent to using (b - a).normalized().
Returns the squared Euclidean distance between this vector and to.
This method runs faster than distance_to(), so prefer it if you need to compare vectors or need the squared distance for some formula.
Returns the inverse of the vector. This is the same as Vector4(1.0 / v.x, 1.0 / v.y, 1.0 / v.z, 1.0 / v.w).
Returns true if this vector and to are approximately equal, by running is_equal_approx() on each component.
Returns true if this vector is finite, by calling is_finite() on each component.
Returns true if this vector's values are approximately zero, by running is_zero_approx() on each component.
This method is faster than using is_equal_approx() with one value as a zero vector.
Returns the squared length (squared magnitude) of this vector.
This method runs faster than length(), so prefer it if you need to compare vectors or need the squared distance for some formula.
Returns the result of the linear interpolation between this vector and to by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
Returns the component-wise maximum of this and with, equivalent to Vector4(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z), maxf(w, with.w)).
Returns the axis of the vector's highest value. See AXIS_* constants. If all components are equal, this method returns AXIS_X.
Returns the component-wise maximum of this and with, equivalent to Vector4(maxf(x, with), maxf(y, with), maxf(z, with), maxf(w, with)).
Returns the component-wise minimum of this and with, equivalent to Vector4(minf(x, with.x), minf(y, with.y), minf(z, with.z), minf(w, with.w)).
Returns the axis of the vector's lowest value. See AXIS_* constants. If all components are equal, this method returns AXIS_W.
Returns the component-wise minimum of this and with, equivalent to Vector4(minf(x, with), minf(y, with), minf(z, with), minf(w, with)).
Returns the result of scaling the vector to unit length. Equivalent to v / v.length(). Returns (0, 0, 0, 0) if v.length() == 0. See also is_normalized().
Note: This function may return incorrect values if the input vector length is near zero.
Returns a vector composed of the fposmod() of this vector's components and mod.
Returns a vector composed of the fposmod() of this vector's components and modv's components.
Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
Returns a new vector with each component set to 1.0 if it's positive, -1.0 if it's negative, and 0.0 if it's zero. The result is identical to calling sign() on each component.
Returns a new vector with each component snapped to the nearest multiple of the corresponding component in step. This can also be used to round the components to an arbitrary number of decimals.
Returns a new vector with each component snapped to the nearest multiple of step. This can also be used to round the components to an arbitrary number of decimals.
AXIS_X = 0Enumerated value for the X axis. Returned by max_axis_index() and min_axis_index().
AXIS_Y = 1Enumerated value for the Y axis. Returned by max_axis_index() and min_axis_index().
AXIS_Z = 2Enumerated value for the Z axis. Returned by max_axis_index() and min_axis_index().
AXIS_W = 3Enumerated value for the W axis. Returned by max_axis_index() and min_axis_index().