Skip to main content

Vector3.distance()

Instance method on Vector3.

Description

  • Returns the distance between this Vector3 and the specified Vector3. |

Method Signature

distance(Vector3)

Mathematical Definition

d(\mathbf{a},\mathbf{b})=||\mathbf{a}-\mathbf{b}||

Parameters

  • Vector3: 3D vector input.

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 a = new Vector3(10f, 2f, -5f);
Vector3 b = new Vector3(1f, 0.5f, 3f);
Vector3 result = a.distance(b);

Mathematical Example

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

Visualization