Math: Vector

Nodes in this category perform operations involving vec2 values (points or arrows in 2D space) such as the dot product, normalization, and distance calculations.

Nodes

NodeDetailsPossible Types
Angle Between

Calculates the angle swept between two vectors.

The value is always positive and ranges from 0° (both vectors point the same direction) to 180° (both vectors point opposite directions).

Vec2 → f64
Vec2[] → f64[]
Angle To

Calculates the angle needed for a rightward-facing object placed at the observer position to turn so it points toward the target position.

Vec2 → f64
Vec2[] → f64[]
Transform → f64
Transform[] → f64[]
Combine Vec2

Composes a vec2 from its X and Y components.

The inverse of this node is Split Vec2, which decomposes a vec2 back into its X and Y components.

→ Vec2
→ Vec2[]
Dot Product

The dot product operation (·) calculates the degree of similarity of a vec2 pair based on their angles and lengths.

Calculated as ‖a‖‖b‖cos(θ), it represents the product of their lengths (‖a‖‖b‖) scaled by the alignment of their directions (cos(θ)).

The output ranges from the positive to negative product of their lengths based on when they are pointing in the same or opposite directions.

If any vector has zero length, the output is 0.

Vec2 → f64
Vec2[] → f64[]
Extract XY

Obtains the X or Y component of a vec2.

The inverse of this node is Combine Vec2, which composes a vec2 from its X and Y components.

Vec2 → f64
Vec2[] → f64[]
Magnitude

The magnitude operator (‖x‖) calculates the length of a vec2, which is the distance from the base to the tip of the arrow represented by the vector.

Vec2 → f64
Vec2[] → f64[]
Normalize

Scales the input vector to unit length while preserving its direction. This is equivalent to dividing the input vector by its own magnitude.

Returns 0 when the input vector has zero length.

Vec2 → Vec2
Vec2[] → Vec2[]