Skip to main content

Vector3.length()

Instance method on Vector3.

Description

  • Returns the length (magnitude) of this Vector3. |

Method Signature

length()

Mathematical Definition

||\mathbf{v}||=\sqrt{x^2+y^2+z^2}

Parameters

  • None.

Returns

  • float: returned by overloads of this method.

Mutability

  • Does not modify the current vector unless explicitly using a Local/Equal variant.

Edge Cases

  • Zero vectors can produce degenerate outputs for geometric methods.
  • NaN and Infinity inputs propagate according to IEEE-754 floating-point behavior.
  • Repeated operations may accumulate floating-point precision error.

Usage Example

Vector3 delta = enemy.getPosition().subtract(player.getPosition());
if (delta.length() < 3f) {
print("Inside interaction radius");
}

Mathematical Example

Example input/output depends on overload; for vector arithmetic operations this is typically computed per-component.

Visualization