Options
All
  • Public
  • Public/Protected
  • All
Menu

Contains the definition of a Vector comprising 4 numbers and associated transformations.

author

Richard Greenlees

author

Kai Burjack

author

F. Neurath

Hierarchy

  • Vector4

Index

Constructors

constructor

  • Create a new Vector4 of (0, 0, 0, 1).

    Returns Vector4

  • Create a new Vector4 with the same values as v.

    Parameters

    • v: Vector4
           the <a href="Vector4.html">Vector4</a> to copy the values from
      

    Returns Vector4

  • Create a new Vector4 with the first three components from the given v and the given w.

    Parameters

    • v: Vector3
           the <a href="Vector3.html">Vector3</a>
      
    • w: number
           the w component
      

    Returns Vector4

  • Create a new Vector4 with the first two components from the given v and the given z and w.

    Parameters

    • v: Vector2
           the <a href="Vector2.html">Vector2</a>
      
    • z: number
           the z component
      
    • w: number
           the w component
      

    Returns Vector4

  • Create a new Vector4 and initialize all four components with the given value.

    Parameters

    • d: number
           the value of all four components
      

    Returns Vector4

  • Create a new Vector4 with the given component values.

    Parameters

    • x: number
           the x component
      
    • y: number
           the y component
      
    • z: number
           the z component
      
    • w: number
           the w component
      

    Returns Vector4

  • Create a new Vector4 and initialize its four components from the first four elements of the given array.

    Parameters

    • xyzw: number[]
           the array containing at least four elements
      

    Returns Vector4

Properties

w

w: number

The w component of the vector.

x

x: number

The x component of the vector.

y

y: number

The y component of the vector.

z

z: number

The z component of the vector.

Methods

absolute

add

  • Add the supplied vector to this one.

    Parameters

    Returns Vector4

    this

  • Add (x, y, z, w) to this.

    Parameters

    • x: number
           the x component to add
      
    • y: number
           the y component to add
      
    • z: number
           the z component to add
      
    • w: number
           the w component to add
      
    • Optional dest: Vector4

    Returns Vector4

    this

angle

angleCos

applyFunction

ceil

  • Set each component of this vector to the smallest (to: closest negative infinity) {@code number} value that is greater than or equal to that component and is equal to a mathematical integer.

    Parameters

    Returns Vector4

    this

clone

distance

  • distance(v: Vector4): number
  • distance(x: number, y: number, z: number, w: number): number

distanceSquared

  • distanceSquared(v: Vector4): number
  • distanceSquared(x: number, y: number, z: number, w: number): number

div

dot

  • dot(v: Vector4): number
  • dot(x: number, y: number, z: number, w: number): number

equals

  • equals(v: Vector4, delta: number): boolean
  • equals(x: number, y: number, z: number, w: number, delta?: number): boolean

floor

  • Set each component of this vector to the largest (to: closest positive infinity) {@code number} value that is less than or equal to that component and is equal to a mathematical integer.

    Parameters

    Returns Vector4

    this

fma

get

hermite

isFinite

  • isFinite(): boolean

length

  • length(): number

lengthSquared

  • lengthSquared(): number

lerp

  • Linearly numbererpolate this and other using the given numbererpolation factor t and store the result in this.

    If t is 0.0 then the result is this. If the numbererpolation factor is 1.0 then the result is other.

    Parameters

    • other: Vector4
           the other vector
      
    • t: number
           the numbererpolation factor between 0.0 and 1.0
      
    • Optional dest: Vector4

    Returns Vector4

    this

max

  • Set the components of this vector to be the component-wise maximum of this and the other vector.

    Parameters

    Returns Vector4

    this

maxComponent

  • maxComponent(): number

min

  • Set the components of this vector to be the component-wise minimum of this and the other vector.

    Parameters

    Returns Vector4

    this

minComponent

  • minComponent(): number

mul

mulAdd

  • Add the component-wise multiplication of this * a to b and store the result in this.

    Parameters

    Returns Vector4

    this

  • Add the component-wise multiplication of this * a to b and store the result in this.

    Parameters

    • a: number
           the multiplicand
      
    • b: Vector4
           the addend
      
    • Optional dest: Vector4

    Returns Vector4

    this

mulAffine

mulAffineTranspose

mulProject

mulTranspose

  • Multiply the transpose of the given matrix mat with this Vector4 and store the result in this.

    Parameters

    • mat: Matrix4
           the matrix whose transpose to multiply the vector with
      
    • Optional dest: Vector4

    Returns Vector4

    this

negate

normalize

normalize3

rotate

  • Transform this vector by the given quaternion quat and store the result in this.

    see

    Quaterniond#transform(Vector4)

    Parameters

    Returns Vector4

    this

rotateAxis

  • rotateAxis(angle: number, x: number, y: number, z: number, dest?: Vector4): Vector4
  • Rotate this vector the specified radians around the given rotation axis.

    Parameters

    • angle: number
           the angle in radians
      
    • x: number
           the x component of the rotation axis
      
    • y: number
           the y component of the rotation axis
      
    • z: number
           the z component of the rotation axis
      
    • Optional dest: Vector4

    Returns Vector4

    this

rotateX

  • Rotate this vector the specified radians around the X axis.

    Parameters

    • angle: number
           the angle in radians
      
    • dest: Vector4

    Returns Vector4

    this

rotateY

  • Rotate this vector the specified radians around the Y axis.

    Parameters

    • angle: number
           the angle in radians
      
    • dest: Vector4

    Returns Vector4

    this

rotateZ

  • Rotate this vector the specified radians around the Z axis.

    Parameters

    • angle: number
           the angle in radians
      
    • dest: Vector4

    Returns Vector4

    this

round

  • Set each component of this vector to the closest number that is equal to a mathematical integer with rounding to positive infinity.

    Parameters

    Returns Vector4

    this

set

  • Set this Vector4 to the values of the given v.

    Parameters

    • v: Vector4
           the vector whose values will be copied numbero this
      

    Returns Vector4

    this

  • Set the x, y, z: and components of this to the components of v and the w component to w.

    Parameters

    • v: Vector3
           the <a href="Vector3.html">Vector3</a> to copy
      
    • w: number
           the w component
      

    Returns Vector4

    this

  • Set the x and y components from the given v and the z and w components to the given z and w.

    Parameters

    • v: Vector2
           the <a href="Vector2.html">Vector2</a>
      
    • z: number
           the z component
      
    • w: number
           the w component
      

    Returns Vector4

    this

  • Set the x, y, z, w: and components to the supplied value.

    Parameters

    • d: number
           the value of all four components
      

    Returns Vector4

    this

  • Set the x, y, z, w: and components to the supplied values.

    Parameters

    • x: number
           the x component
      
    • y: number
           the y component
      
    • z: number
           the z component
      
    • w: number
           the w component
      

    Returns Vector4

    this

  • Set the x, y, components: z to the supplied values.

    Parameters

    • x: number
           the x component
      
    • y: number
           the y component
      
    • z: number
           the z component
      

    Returns Vector4

    this

  • Set the four components of this vector to the first four elements of the given array.

    Parameters

    • xyzw: number[]
           the array containing at least four elements
      

    Returns Vector4

    this

setComponent

  • setComponent(component: number, value: number): Vector4
  • Set the value of the specified component of this vector.

    throws

    IllegalArgumentException if component is not within [0..3]

    Parameters

    • component: number
           the component whose value to set, : within<code>[0..3]</code>
      
    • value: number
           the value to set
      

    Returns Vector4

    this

smoothStep

sub

  • Subtract the supplied vector from this one and store the result in dest.

    Parameters

    • v: Vector4
           the vector to subtract
      
    • Optional dest: Vector4
           will hold the result
      

    Returns Vector4

    dest

  • Subtract (x, y, z, w) from this one and store the result in dest.

    Parameters

    • x: number
           the x component to subtract
      
    • y: number
           the y component to subtract
      
    • z: number
           the z component to subtract
      
    • w: number
           the w component to subtract
      
    • Optional dest: Vector4

    Returns Vector4

    dest

toBlockLocation

  • toBlockLocation(): BlockLocation

toLocation

  • toLocation(): Location

toString

  • toString(formatter?: (x: number) => string): String
  • Return a string representation of this vector by formatting the vector components with the given {@link NumberFormat}.

    Parameters

    • Optional formatter: (x: number) => string
           the {@link NumberFormat} used to format the vector components with
      
        • (x: number): string
        • Parameters

          • x: number

          Returns string

    Returns String

    the string representation

zero

Static distance

  • distance(x1: number, y1: number, z1: number, w1: number, x2: number, y2: number, z2: number, w2: number): number
  • Return the distance between (x1, y1, z1, w1) and (x2, y2, z2, w2).

    Parameters

    • x1: number
           the x component of the first vector
      
    • y1: number
           the y component of the first vector
      
    • z1: number
           the z component of the first vector
      
    • w1: number
           the w component of the first vector
      
    • x2: number
           the x component of the second vector
      
    • y2: number
           the y component of the second vector
      
    • z2: number
           the z component of the second vector
      
    • w2: number
           the 2 component of the second vector
      

    Returns number

    the euclidean distance

Static distanceSquared

  • distanceSquared(x1: number, y1: number, z1: number, w1: number, x2: number, y2: number, z2: number, w2: number): number
  • Return the squared distance between (x1, y1, z1, w1) and (x2, y2, z2, w2).

    Parameters

    • x1: number
           the x component of the first vector
      
    • y1: number
           the y component of the first vector
      
    • z1: number
           the z component of the first vector
      
    • w1: number
           the w component of the first vector
      
    • x2: number
           the x component of the second vector
      
    • y2: number
           the y component of the second vector
      
    • z2: number
           the z component of the second vector
      
    • w2: number
           the w component of the second vector
      

    Returns number

    the euclidean distance squared

Static lengthSquared

  • lengthSquared(x: number, y: number, z: number, w: number): number
  • Get the length squared of a 4-dimensional number-precision vector.

    author

    F. Neurath

    Parameters

    • x: number

      The vector's x component

    • y: number

      The vector's y component

    • z: number

      The vector's z component

    • w: number

      The vector's w component

    Returns number

    the length squared of the given vector

Static magnitude

  • magnitude(x: number, y: number, z: number, w: number): number
  • Get the length of a 4-dimensional number-precision vector.

    author

    F. Neurath

    Parameters

    • x: number

      The vector's x component

    • y: number

      The vector's y component

    • z: number

      The vector's z component

    • w: number

      The vector's w component

    Returns number

    the length of the given vector

Generated using TypeDoc