A 4 dimensional vector.


Maths

Hierarchy (view full)

Constructors

  • Creates a vector4.

    Parameters

    • Optional pX: number
      in
      x value of the vector.
    • Optional pY: number
      in
      y value of the vector.
    • Optional pZ: number
      in
      z value of the vector.
    • Optional pW: number
      in
      w value of the vector.

    Returns Vector4

    A new Vector4.

Properties

w: number

w value of the vector, i.e. fourth component.

x: number

x value of the vector, i.e. first component.

y: number

y value of the vector, i.e. second component.

z: number

z value of the vector, i.e. third component.

Methods

  • Computes this + (pX,pY,pZ,pW) and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pX: number
      in
      x value of the vector to add.
    • pY: number
      in
      y value of the vector to add.
    • pZ: number
      in
      z value of the vector to add.
    • pW: number
      in
      w value of the vector to add.
    • Optional pOut: Vector4
      out
      The resulting vector4.

    Returns Vector4

    pOut.

  • Computes this + pOther and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pOther: Vector4
      in
      The vector4 to add.
    • Optional pOut: Vector4
      out
      The resulting vector4.

    Returns Vector4

    pOut.

  • Copies this to pOut vector.

    If pOut is not supplied, a new vector4 is allocated.

    Parameters

    • Optional pOut: Vector4
      out
      The vector4 to copy to.

    Returns Vector4

    The copied vector.

  • Computes the euclidean distance between this and pVec.

    Warning, this function does not assume that w=1, and does not assume the vector4 as a vector3. The w component is used in the calculation.

    Parameters

    • pVec: Vector4
      in
      The other vector to compute the distance to.

    Returns number

    The distance between this and pVec.

  • Computes the dot product between this and (pX,pY,pZ,pW).

    Parameters

    • pX: number
      in
      x value of the vector to compute the dot with.
    • pY: number
      in
      y value of the vector to compute the dot with.
    • pZ: number
      in
      z value of the vector to compute the dot with.
    • pW: number
      in
      w value of the vector to compute the dot with.

    Returns number

    The dot product ( dot(this, (pX,pY,pZ,pW)) ).

  • Computes the dot product between this and pOther.

    Parameters

    • pOther: Vector4
      in
      The other Vector4 to compute the dot with.

    Returns number

    The dot product ( dot(this, pOther) ).

  • Tells if the two vectors are strictly identical.

    If you want to tell if the two vector4 represent the same 3D cartesian point, use isHomogeneousEqual.

    Parameters

    • pOtherVector: Vector4
      in
      The other vector to compare to.

    Returns boolean

    true if the two vectors are strictly identical.

  • Sets the content of the Vector from a former call to toJSON.

    Parameters

    • pVectorData: string | Object
      in
      Internal Vector4 data to set.

    Returns boolean

    true if the data is set.

  • Tells if the two vectors are homogeneously equivalent.

    This function tells if the two Vector4 represent the same 3D cartesian point.

    Parameters

    • pOtherVector: Vector4
      in
      The other vector to compare to.

    Returns boolean

    true if the two vectors are homogeneously equivalent.

  • Gets the euclidean length of this.

    Warning, this function does not assume that w=1, and does not assume the vector4 as a vector3. The w component is used in the calculation.

    Returns number

    The length of this.

  • Gets the squared euclidean length of this.

    Warning, this function does not assume that w=1, and does not assume the vector4 as a vector3. The w component is used in the calculation.

    Returns number

    The squared length of this.

  • Computes the linear interpolation between this and (pX,pY,pZ,pW) and stores the result in pOut.

    pOut = this + pTime x ( (pX,pY,pZ,pW) - this).
    If pTime=0, pOut = this.
    If pTime=1, pOut = (pX,pY,pZ,pW).

    If pOut is omitted, the result of the interpolation is stored in this.

    No check is done to ensure pTime is in the range [0,1].

    Parameters

    • pX: number
      in
      x value of the destination vector.
    • pY: number
      in
      y value of the destination vector.
    • pZ: number
      in
      z value of the destination vector.
    • pW: number
      in
      w value of the destination vector.
    • pTime: number
      in
      Interpolation parameter in the range [0,1].
    • Optional pOut: Vector4
      out
      The resulting vector4.

    Returns Vector4

    pOut.

  • Computes the linear interpolation between this and pOther and stores the result in pOut.

    pOut = this + pTime x ( pOther - this).
    If pTime=0, pOut = this.
    If pTime=1, pOut = pOther.

    If pOut is omitted, the result of the interpolation is stored in this.

    No check is done to ensure pTime is in the range [0,1].

    Parameters

    • pOther: Vector4
      in
      The destination vector.
    • pTime: number
      in
      Interpolation parameter in the range [0,1].
    • Optional pOut: Vector4
      out
      The resulting vector4.

    Returns Vector4

    pOut.

  • Computes the opposite of this (-this) and stores the result in pOut.

    If pOut is omitted, the result is stored in this.

    Parameters

    • Optional pOut: Vector4
      out
      The resulting vector.

    Returns Vector4

    pOut.

  • Computes the normalization of this (i.e. scales this such that pOut.length() == 1, a zero vector is left unchanged) and stores the result in pOut.

    If pOut is omitted, this is normalized.

    Warning, this function does not assume that w=1, and does not assume the vector4 as a vector3. The w component is used in the calculation.

    Parameters

    • Optional pOut: Vector4
      out
      The resulting vector.

    Returns Vector4

    pOut.

  • Computes the euclidean distance from the plane represented by this to pPoint.

    The Vector4 can be the parametric equation of a plane in the form P: {t,u,v} / at + bu + cv = d.
    So, with the components x,y,z,w of the vector 4 : {t,u,v} / xt + yu + zv = w where (x,y,z) is the normal vector of the plane.

    Parameters

    • pPoint: Vector3
      in
      The distance to compute the distance to.

    Returns number

    The distance between the plane represented by this and pPoint.

  • Computes the scale of this by the scalar pScalar, and stores the result in pOut.

    pOut = pScalar x this.

    If pOut is omitted, the result is stored in this.

    Parameters

    • pScalar: number
      in
      The scale factor.
    • Optional pOut: Vector4
      out
      The resulting vector.

    Returns Vector4

    pOut.

  • Sets the vector components.

    Parameters

    • pX: number
      in
      x value.
    • pY: number
      in
      y value.
    • pZ: number
      in
      z value.
    • pW: number
      in
      w value.

    Returns this

    this.

  • Sets this Vector4 to be the representation of the plane defined by its normal and a point of this plane.

    No check is done to ensure that pNormal is normalized.

    The Vector4 can be the parametric equation of a plane in the form P: {t,u,v} / at + bu + cv = d.
    So, with the components x,y,z,w of the vector 4 : {t,u,v} / xt + yu + zv = w where (x,y,z) is the normal vector of the plane.

    Parameters

    • pNormal: Vector3
      in
      The normal of the plane.
    • pPlanePoint: Vector3
      in
      A point that belongs to the plane.

    Returns this

    this.

  • Computes the squared euclidean distance between this and pVec.

    Warning, this function does not assume that w=1, and does not assume the vector4 as a vector3. The w component is used in the calculation.

    Parameters

    • pVec: Vector4
      in
      The other vector to compute the distance to.

    Returns number

    The squared distance between this and pVec.

  • Computes this - (pX,pY,pZ,pW) and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pX: number
      in
      x value of the vector to subtract.
    • pY: number
      in
      y value of the vector to subtract.
    • pZ: number
      in
      z value of the vector to subtract.
    • pW: number
      in
      w value of the vector to subtract.
    • Optional pOut: Vector4
      out
      The resulting vector4.

    Returns Vector4

    pOut.

  • Computes this - pOther and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pOther: Vector4
      in
      The vector4 to subtract.
    • Optional pOut: Vector4
      out
      The resulting Vector4.

    Returns Vector4

    pOut.

  • Serializes the given Vector4 to JSON.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The JSON representation of the object.

  • Gets the string representation of the vector.

    Returns string

    The string representation of the vector.