Geometry

Vector rotations

  • Rotate 90ΒΊ clockwise: new_vector = Vector2(y, -x) .

  • Rotate 90ΒΊ counterclockwise: new_vector = Vector2(-y, x) .

Mathematical manipulations

  • Returns a number multiple of the given 'steps', rounding to the nearest:
    float snappedf(x : float, step : float)

  • Rounds a float to the nearest x:
    float roundf(x : float)

  • Checks if float is approximately zero:
    bool is_zero_approx(x : float)

  • Checks if float is approximately equal to something:
    bool is_equal_approx(a : float, b : float)

  • Counts the number of decimal places:
    int step_decimals(x : float)

  • Clamp variable ranges:
    vel.x = clamp(vel.x, -VEL_MAX, VEL_MAX)

Node3D: Rotations

  • (Rotates the "local transform") (?), around an axis defined in 'local coordinates':
    rotate_object_local(_axis, _ang_rad)

  • (Rotates the "local transform") (?), around an axis defined in 'parent coordinates (sometimes coinciding with global)':
    rotate(_axis, _ang_rad)
    rotate_x(_ang_rad)
    rotate_y(_ang_rad)
    rotate_z(_ang_rad)

  • (Rotates the "global transform") (?), around an axis defined in 'global coordinates':
    global_rotate(_axis, _ang_rad)

Node3D Transform

  • Build an identity transform, with vectors in default direction centered at the origin.

    • var trans = Transform()

  • Build a transform based on identity, with vectors in default direction.

    • var base = Basis()

    • or

    • trans.basis = Basis()

  • Orthogonalize and normalize the Transform, ensuring axes are 90ΒΊ apart and normalized, giving a scale of -1 or 1.

    • trans = trans.orthonormalized()

  • Rotate in global space:

    • trans = trans.rotated(_axis, _ang_rad)

  • Rotate in local/self space:

    • trans = trans.rotated_local(_axis, _ang_rad)

  • Translate in global space:

    • trans = trans.translated(_offset)

  • Translate in local/self space:

    • trans = trans.translated_local(_offset)

Node2D Rotations and Translations

rotation += (PI/16 + get_rotation()) *  delta
translate(Vector2(0, G/2))

CSG