Vector3

Category: Built-In Types

Brief Description

Vector class, which performs basic 3D vector math operations.

Member Variables

  • float x - The vector’s x component.
  • float y - The vector’s y component.
  • float z - The vector’s z component.

Numeric Constants

  • AXIS_X = 0 — Enumerated value for the X axis. Returned by max_axis and min_axis.
  • AXIS_Y = 1 — Enumerated value for the Y axis.
  • AXIS_Z = 2 — Enumerated value for the Z axis.

Description

Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.

Member Function Description

Returns a Vector3 with the given components.

Returns a new vector with all components in absolute values (i.e. positive).

Returns the minimum angle to the given vector.

Returns the vector “bounced off” from a plane defined by the given normal.

Returns a new vector with all components rounded up.

Returns the cross product with b.

Performs a cubic interpolation between vectors pre_a, a, b, post_b (a is current), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

Returns the squared distance to b. Prefer this function over distance_to if you need to sort vectors or need the squared distance for some formula.

Returns the distance to b.

Returns the dot product with b.

Returns a new vector with all components rounded down.

Returns the inverse of the vector. This is the same as Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z ).

  • bool is_normalized ( )

Returns true if the vector is normalized.

Returns the vector’s length.

  • float length_squared ( )

Returns the vector’s length squared. Prefer this function over length if you need to sort vectors or need the squared length for some formula.

Returns the result of the linear interpolation between this vector and b by amount t. t is in the range of 0.0 - 1.0, a percentage of how far along the interpolation is.

  • int max_axis ( )

Returns the axis of the vector’s largest value. See AXIS_* constants.

  • int min_axis ( )

Returns the axis of the vector’s smallest value. See AXIS_* constants.

Returns the vector scaled to unit length. Equivalent to v / v.length().

Returns the outer product with b.

Returns the vector reflected from a plane defined by the given normal.

Rotates the vector around a given axis by phi radians. The axis must be a normalized vector.

Returns the result of SLERP between this vector and “b”, by amount “t”. “t” should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

Both vectors need to be normalized.

Returns the component of the vector along a plane defined by the given normal.

Returns a copy of the vector, snapped to the lowest neared multiple.

  • Basis to_diagonal_matrix ( )

Returns a diagonal matrix with the vector as main diagonal.