Small World Engine API Reference - v0.46.1
    Preparing search index...

    Interface Vector

    Interface representing a mathematical vector with basic operations. Designed to be implemented by Vector2D and Vector3D.

    interface Vector {
        length(): number;
        lengthSq(): number;
        normalize(): Vector;
        scale(s: number): Vector;
    }

    Implemented by

    Index

    Methods

    • Calculates the Euclidean length of the vector.

      Returns number

      The length.

    • Calculates the squared length of the vector (faster than length()).

      Returns number

      The squared length.

    • Scales the vector components by a scalar value.

      Parameters

      • s: number

        The scalar factor.

      Returns Vector

      This vector instance for chaining.