Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Vector4¶
A 4D vector using floating point coordinates.
Description¶
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
.
Properties¶
|
||
|
||
|
||
|
Constructors¶
Vector4 ( ) |
|
Methods¶
abs ( ) const |
|
ceil ( ) const |
|
cubic_interpolate ( Vector4 b, Vector4 pre_a, Vector4 post_b, float weight ) const |
|
cubic_interpolate_in_time ( Vector4 b, Vector4 pre_a, Vector4 post_b, float weight, float b_t, float pre_a_t, float post_b_t ) const |
|
direction_to ( Vector4 to ) const |
|
distance_squared_to ( Vector4 to ) const |
|
distance_to ( Vector4 to ) const |
|
floor ( ) const |
|
inverse ( ) const |
|
is_equal_approx ( Vector4 to ) const |
|
is_finite ( ) const |
|
is_normalized ( ) const |
|
is_zero_approx ( ) const |
|
length ( ) const |
|
length_squared ( ) const |
|
max_axis_index ( ) const |
|
min_axis_index ( ) const |
|
normalized ( ) const |
|
round ( ) const |
|
sign ( ) const |
|
Operators¶
operator != ( Vector4 right ) |
|
operator * ( Projection right ) |
|
operator * ( Vector4 right ) |
|
operator * ( float right ) |
|
operator * ( int right ) |
|
operator + ( Vector4 right ) |
|
operator - ( Vector4 right ) |
|
operator / ( Vector4 right ) |
|
operator / ( float right ) |
|
operator / ( int right ) |
|
operator < ( Vector4 right ) |
|
operator <= ( Vector4 right ) |
|
operator == ( Vector4 right ) |
|
operator > ( Vector4 right ) |
|
operator >= ( Vector4 right ) |
|
operator [] ( int index ) |
|
operator unary+ ( ) |
|
operator unary- ( ) |
Constants¶
AXIS_X = 0
Enumerated value for the X axis. Returned by max_axis_index and min_axis_index.
AXIS_Y = 1
Enumerated value for the Y axis. Returned by max_axis_index and min_axis_index.
AXIS_Z = 2
Enumerated value for the Z axis. Returned by max_axis_index and min_axis_index.
AXIS_W = 3
Enumerated value for the W axis. Returned by max_axis_index and min_axis_index.
ZERO = Vector4(0, 0, 0, 0)
Zero vector, a vector with all components set to 0
.
ONE = Vector4(1, 1, 1, 1)
One vector, a vector with all components set to 1
.
INF = Vector4(inf, inf, inf, inf)
Infinity vector, a vector with all components set to @GDScript.INF.
Property Descriptions¶
float w = 0.0
The vector's W component. Also accessible by using the index position [3]
.
float x = 0.0
The vector's X component. Also accessible by using the index position [0]
.
float y = 0.0
The vector's Y component. Also accessible by using the index position [1]
.
float z = 0.0
The vector's Z component. Also accessible by using the index position [2]
.
Constructor Descriptions¶
Vector4 Vector4 ( )
Constructs a default-initialized Vector4 with all components set to 0
.
Vector4 Vector4 ( Vector4 from )
Constructs a Vector4 as a copy of the given Vector4.
Vector4 Vector4 ( Vector4i from )
Constructs a new Vector4 from the given Vector4i.
Vector4 Vector4 ( float x, float y, float z, float w )
Returns a Vector4 with the given components.
Method Descriptions¶
Vector4 abs ( ) const
Returns a new vector with all components in absolute values (i.e. positive).
Vector4 ceil ( ) const
Returns a new vector with all components rounded up (towards positive infinity).
Vector4 clamp ( Vector4 min, Vector4 max ) const
Returns a new vector with all components clamped between the components of min
and max
, by running @GlobalScope.clamp on each component.
Vector4 cubic_interpolate ( Vector4 b, Vector4 pre_a, Vector4 post_b, float weight ) const
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.
Vector4 cubic_interpolate_in_time ( Vector4 b, Vector4 pre_a, Vector4 post_b, float weight, float b_t, float pre_a_t, float post_b_t ) const
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.
Vector4 direction_to ( Vector4 to ) const
Returns the normalized vector pointing from this vector to to
. This is equivalent to using (b - a).normalized()
.
float distance_squared_to ( Vector4 to ) const
Returns the squared 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.
float distance_to ( Vector4 to ) const
Returns the distance between this vector and to
.