Math: Vec2

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 vec2s.

The angle ranges from -180° to 180° (or -π to π radians) and its sign gives the sweep direction from the "Direction From" input to the "Direction To" input: positive for clockwise, negative for counterclockwise, as drawn in the viewport and matching the direction convention of the Transform node's rotation.

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

Calculates the angle needed for a rightward-facing object placed at the "Position From" point to turn so it points toward the "Position To" point.

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[]
Cross Product

The cross product operation (×) calculates the signed area of the parallelogram formed by a vec2 pair.

The sign gives the rotation direction from the first vec2 to the second: positive for clockwise, negative for counterclockwise, and 0 when both are parallel, as drawn in the viewport.

Vec2 → f64
Vec2[] → f64[]
Distance

Measures the distance between two points, which is the length of the straight line segment connecting them.

Vec2 → f64
Vec2[] → f64[]
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 either vec2 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 it represents.

Vec2 → f64
Vec2[] → f64[]
Normalize

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

Returns 0 when the input vec2 has zero length.

Vec2 → Vec2
Vec2[] → Vec2[]