npm.nicfv.com
    Preparing search index...

    Class Vec3

    Structure for a vector in 3D space.

    Index

    Constructors

    • Create a vector from cartesian coordinates

      Parameters

      • x: number

        The cartesian x-coordinate

      • y: number

        The cartesian y-coordinate

      • z: number = 0

        The cartesian z-coordinate

      Returns Vec3

    Properties

    phi: number

    The angle of the vector in radians, measured from the xy-plane

    r: number

    The magnitude/length of the vector

    theta: number

    The angle of the vector in radians, measured from the x-axis

    x: number

    The cartesian x-coordinate

    y: number

    The cartesian y-coordinate

    z: number = 0

    The cartesian z-coordinate

    Methods

    • Compute the cross product between this vector and another vector

      Parameters

      • other: Vec3

        Arbitrary vector

      Returns Vec3

      v1 x v2

    • Compute the dot product between this vector and another vector

      Parameters

      • other: Vec3

        Arbitrary vector

      Returns number

      v1 . v2

    • Determine if two vectors are equal (or approximately equal)

      Parameters

      • other: Vec3

        Arbitrary vector

      • tolerance: number = 0

        Optional absolute tolerance

      Returns boolean

      true if v1 = v2

    • Subtract another vector from this vector

      Parameters

      • other: Vec3

        Arbitrary vector

      Returns Vec3

      v1 - v2

    • Add this vector and another vector

      Parameters

      • other: Vec3

        Arbitrary vector

      Returns Vec3

      v1 + v2

    • Project this vector onto another vector

      Parameters

      • other: Vec3

        Arbitrary vector

      Returns Vec3

      proj_v2(v1)

    • Scale this vector by a numeric factor

      Parameters

      • factor: number

        Scaling factor

      Returns Vec3

      A scaled vector

    • Get a unit vector in this direction

      Returns Vec3

      v1 (with length 1)

    • Create a vector from polar coordinates

      Parameters

      • r: number

        The magnitude/length of the vector

      • theta: number

        The angle of the vector in radians, measured from the x-axis

      • phi: number = 0

        The angle of the vector in radians, measured from the xy-plane

      Returns Vec3

      A vector created from polar coordinates