ProtoTwin API
    Preparing search index...

    Class Vec3

    Immutable 3D vector.

    Represents vectors and points in 3D space.

    Implements

    Index

    Constructors

    • Constructor.

      Parameters

      • x: number

        The x component.

      • y: number

        The y component.

      • z: number

        The z component.

      Returns Vec3

    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.

    Accessors

    • get nx(): Vec3

      The negative x-axis vector.

      Returns Vec3

    • get ny(): Vec3

      The negative y-axis vector.

      Returns Vec3

    • get nz(): Vec3

      The negative z-axis vector.

      Returns Vec3

    • get one(): Vec3

      The vector with all components set to one.

      Returns Vec3

    • get x(): Vec3

      The x-axis vector.

      Returns Vec3

    • get y(): Vec3

      The y-axis vector.

      Returns Vec3

    • get z(): Vec3

      The z-axis vector.

      Returns Vec3

    • get zero(): Vec3

      The zero vector.

      Returns Vec3

    Methods

    • Converts the vector to a string.

      Returns string

      The string representation of the vector.

    • Adds two vectors.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns Vec3

      The sum of the two vectors.

    • Calculates the shortest unsigned angle between two vectors.

      Parameters

      • v1: IVec3

        The first vector.

      • v2: IVec3

        The second vector.

      Returns number

      The shortest unsigned angle (radians).

      The vectors must have non-zero lengths.

    • Calculates the shortest unsigned angle between two unit vectors.

      Parameters

      • n1: IVec3

        The first unit vector.

      • n2: IVec3

        The second unit vector.

      Returns number

      The shortest unsigned angle (radians).

    • The cross (vector) product of two vectors.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns Vec3

      The cross product.

    • Calculates the unit direction vector from the start point to the end point.

      Parameters

      • start: IVec3

        The start point.

      • end: IVec3

        The end point.

      Returns Vec3

      The unit direction vector.

      The start and end points must not be coincident.

    • Calculates the Euclidean distance between two points.

      Parameters

      • p1: IVec3

        The first point.

      • p2: IVec3

        The second point.

      Returns number

      The distance.

    • Calculates the square of the Euclidean distance between two points.

      Parameters

      • p1: IVec3

        The first point.

      • p2: IVec3

        The second point.

      Returns number

      The square of the distance.

    • Calculates the dot (scalar) product of two vectors.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns number

      The dot product.

    • Determines whether two vectors are exactly equal.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns boolean

      True if the two vectors are exactly equal, false otherwise.

    • Divides the first vector by the second vector component-wise.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns Vec3

      The component-wise division of the first vector by the second vector.

    • Linearly interpolates between two vectors.

      Parameters

      • lhs: IVec3

        The start vector.

      • rhs: IVec3

        The end vector.

      • weight: number

        The interpolation fraction between the two quaternions.

      Returns Vec3

      The interpolated quaternion.

    • Calculates the mid point between the two points.

      Parameters

      • first: IVec3

        The first point.

      • second: IVec3

        The second point.

      Returns Vec3

      The mid point.

    • Negates the vector.

      Parameters

      Returns Vec3

      The negated vector.

    • The magnitude of the vector.

      Parameters

      Returns number

      The length of the vector.

    • Normalizes a vector.

      Parameters

      Returns Vec3

      The unit vector with the same direction.

      The vector must have non-zero length.

    • The square of the magnitude of the vector.

      Parameters

      Returns number

      The length squared of the vector.

    • Determines whether two vectors are not exactly equal.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns boolean

      True if the two vectors are different, false otherwise.

    • Finds a vector orthonormal to the specified unit vector.

      Parameters

      • n: IVec3

        The unit vector.

      Returns Vec3

      The orthonormal vector.

      The specified vector must have non-zero length.

    • Makes the second supplied unit vector orthonormal to the first supplied unit vector.

      Parameters

      • n1: Vec3

        The first unit vector.

      • n2: Vec3

        The second unit vector.

      Returns Vec3

      The orthonormalized second unit vector.

      Uses the Gram-Schmidt process.

    • Determines whether two vectors are (anti-)parallel.

      Parameters

      • v1: IVec3

        The first vector.

      • v2: IVec3

        The second vector.

      • eps: number = 0.000175

        The angular tolerance (radians).

      Returns boolean

      True if the vectors are (anti-)parallel, false otherwise.

      The two vectors are (anti-)parallel if the shortest angle between them is less than the specified tolerance.

    • Determines whether two unit vectors are (anti-)parallel.

      Parameters

      • n1: IVec3

        The first unit vector.

      • n2: IVec3

        The second unit vector.

      • eps: number = 0.000175

        The angular tolerance (radians).

      Returns boolean

      True if the unit vectors are (anti-)parallel, false otherwise.

      The two unit vectors are (anti-)parallel if the shortest angle between them is less than the specified tolerance.

    • Creates a random unit vector.

      Returns Vec3

      The random unit vector.

    • Multiplies the two vectors component-wise.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns Vec3

      The component-wise product of the two vectors.

    • Scales a vector uniformly.

      Parameters

      • lhs: IVec3

        The vector.

      • rhs: number

        The uniform scale factor.

      Returns Vec3

      The scaled vector.

    • Calculates the shortest signed angle between two vectors.

      Parameters

      • start: IVec3

        The vector from which the angle is measured.

      • end: IVec3

        The vector to which the angle is measured.

      • n: IVec3

        The plane in which the vectors lie.

      Returns number

      The shortest signed angle (radians).

      The sign of the angle is determined by the specified plane normal. The vectors must lie in the plane.

    • Calculates the shortest signed angle between two unit vectors.

      Parameters

      • start: IVec3

        The unit vector from which the angle is measured.

      • end: IVec3

        The unit vector to which the angle is measured.

      • n: IVec3

        The plane in which the vectors lie.

      Returns number

      The shortest signed angle (radians).

      The sign of the angle is determined by the specified plane normal. The unit vectors must lie in the plane.

    • Subtracts the second vector from the first vector.

      Parameters

      • lhs: IVec3

        The first vector.

      • rhs: IVec3

        The second vector.

      Returns Vec3

      The subtraction of the second vector from the first vector.