Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

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

float

w

0.0

float

x

0.0

float

y

0.0

float

z

0.0

Constructors

Vector4

Vector4 ( )

Vector4

Vector4 ( Vector4 from )

Vector4

Vector4 ( Vector4i from )

Vector4

Vector4 ( float x, float y, float z, float w )

Methods

Vector4

abs ( ) const

Vector4

ceil ( ) const

Vector4

clamp ( Vector4 min, Vector4 max ) const

Vector4

cubic_interpolate ( Vector4 b, Vector4 pre_a, Vector4 post_b, float weight ) const

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

Vector4

direction_to ( Vector4 to ) const

float

distance_squared_to ( Vector4 to ) const

float

distance_to ( Vector4 to ) const

float

dot ( Vector4 with ) const

Vector4

floor ( ) const

Vector4

inverse ( ) const

bool

is_equal_approx ( Vector4 to ) const

bool

is_finite ( ) const

bool

is_normalized ( ) const

bool

is_zero_approx ( ) const

float

length ( ) const

float

length_squared ( ) const

Vector4

lerp ( Vector4 to, float weight ) const

int

max_axis_index ( ) const

int

min_axis_index ( ) const

Vector4

normalized ( ) const

Vector4

posmod ( float mod ) const

Vector4

posmodv ( Vector4 modv ) const

Vector4

round ( ) const

Vector4

sign ( ) const

Vector4

snapped ( Vector4 step ) const

Operators

bool

operator != ( Vector4 right )

Vector4

operator * ( Projection right )

Vector4

operator * ( Vector4 right )

Vector4

operator * ( float right )

Vector4

operator * ( int right )

Vector4

operator + ( Vector4 right )

Vector4

operator - ( Vector4 right )

Vector4

operator / ( Vector4 right )

Vector4

operator / ( float right )

Vector4

operator / ( int right )

bool

operator < ( Vector4 right )

bool

operator <= ( Vector4 right )

bool

operator == ( Vector4 right )

bool

operator > ( Vector4 right )

bool

operator >= ( Vector4 right )

float

operator [] ( int index )

Vector4

operator unary+ ( )

Vector4

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)