starry-math
    Preparing search index...

    Class Vector3

    Represents a 3D vector with x, y, and z components. Provides various vector operations for 3D mathematics and transformations.

    Index

    Constructors

    • Creates a new Vector3 instance

      Parameters

      • x: number = 0

        The x component of the vector. Defaults to 0

      • y: number = 0

        The y component of the vector. Defaults to 0

      • z: number = 0

        The z component of the vector. Defaults to 0

      Returns Vector3

    Properties

    x: number

    The x component of the vector

    y: number

    The y component of the vector

    z: number

    The z component of the vector

    Methods

    • Adds another vector to this vector

      Parameters

      Returns this

      Returns this vector for method chaining

    • Multiplies this vector by a 4x4 matrix

      Parameters

      • matrix: IMatrix4

        The 4x4 matrix to apply

      Returns this

      Returns this vector for method chaining

    • Copies values from another vector into this vector

      Parameters

      • source: Vector3

        The vector to copy from

      Returns this

      Returns this vector for method chaining

    • Computes the cross product of this vector with another vector

      Parameters

      • vector: Vector3

        The other vector for the cross product

      Returns this

      Returns this vector with cross product result for method chaining

    • Computes the cross product of two vectors and stores the result in this vector

      Parameters

      Returns this

      Returns this vector with cross product result for method chaining

    • Computes the distance between this vector and another vector

      Parameters

      • vector: Vector3

        The other vector to measure distance to

      Returns number

      The distance between the vectors

    • Computes the squared distance between this vector and another vector (avoids sqrt for performance)

      Parameters

      • vector: Vector3

        The other vector to measure distance to

      Returns number

      The squared distance between the vectors

    • Divides this vector component-wise by another vector

      Parameters

      • vector: Vector3

        The vector to divide by

      Returns this

      Returns this vector for method chaining

    • Divides this vector by a scalar

      Parameters

      • num: number

        The scalar value to divide by

      Returns this

      Returns this vector for method chaining

    • Computes the dot product of this vector with another vector

      Parameters

      • vector: Vector3

        The other vector for the dot product

      Returns number

      The dot product result

    • Compares this vector with another vector for equality

      Parameters

      • vector: Vector3

        The vector to compare with

      Returns boolean

      True if vectors are equal, false otherwise

    • Computes the length (magnitude) of this vector

      Returns number

      The length of the vector

    • Computes the squared length of this vector (avoids sqrt for performance)

      Returns number

      The squared length of the vector

    • Multiplies this vector component-wise by another vector

      Parameters

      • vector: Vector3

        The vector to multiply by

      Returns this

      Returns this vector for method chaining

    • Multiplies this vector by a scalar

      Parameters

      • num: number

        The scalar value to multiply by

      Returns this

      Returns this vector for method chaining

    • Rotates the vector around an axis by a given angle Based on Rodrigues' rotation formula

      Parameters

      • angle: number

        The rotation angle in radians

      • axis: Coordinate3D

        The rotation axis

      Returns this

      Returns this vector for method chaining

    • Sets the components of this vector

      Parameters

      • x: number

        The new x component

      • y: number

        The new y component

      • z: number

        The new z component

      Returns this

      Returns this vector for method chaining

    • Sets the x component of this vector

      Parameters

      • x: number

        The new x component

      Returns this

      Returns this vector for method chaining

    • Sets the y component of this vector

      Parameters

      • y: number

        The new y component

      Returns this

      Returns this vector for method chaining

    • Sets the z component of this vector

      Parameters

      • z: number

        The new z component

      Returns this

      Returns this vector for method chaining

    • Subtracts another vector from this vector

      Parameters

      • vector: Vector3

        The vector to subtract

      Returns this

      Returns this vector for method chaining

    • Converts this vector to an array of its components

      Returns [number, number, number]

      An array containing the vector's components [x, y, z]

    • Transforms the direction of this vector by a 4x4 matrix

      Parameters

      • matrix: IMatrix4

        The 4x4 matrix to apply

      Returns this

      Returns this vector for method chaining

    • Normalizes this vector to unit length (length = 1)

      Returns this

      Returns this vector for method chaining