Description

a vector class that uses tensorflow tensors to represent vectors

Export

Vector

Property

the components of the vector

Hierarchy

  • Vector

Constructors

  • Description

    creates an instance of Vector.

    Parameters

    • components: number[] | Tensor<Rank>

      the components of the vector

    Returns Vector

Properties

components: Tensor<Rank>

Description

the components of the vector

Methods

  • Description

    returns a new vector that is the current vector plus the vector passed in as an argument

    Returns

    a new vector that is the current vector plus the vector passed in as an argument

    Parameters

    • components: number[]

    Returns Vector

  • Description

    returns the angle between the current vector and the vector passed in as an argument

    Returns

    the angle between the current vector and the vector passed in as an argument

    Parameters

    Returns number

  • Description

    returns a new vector that is the cross product of the current vector and the vector passed in as an argument

    Returns

    a new vector that is the cross product of the current vector and the vector passed in as an argument

    Parameters

    Returns Vector

  • Description

    returns the dot product of the current vector and the vector passed in as an argument

    Returns

    Parameters

    Returns number

  • Description

    returns true if the current vector and the vector passed in as an argument are equal

    Returns

    true if the current vector and the vector passed in as an argument are equal

    Parameters

    Returns boolean

  • Description

    returns the components of the vector as an array

    Returns

    the components of the vector as an array

    Returns number[]

  • Description

    returns true if the current vector and the vector passed in as an argument have opposite directions

    Returns

    true if the current vector and the vector passed in as an argument have opposite directions

    Parameters

    Returns boolean

  • Description

    returns true if the current vector and the vector passed in as an argument have the same direction

    Returns

    true if the current vector and the vector passed in as an argument have the same direction

    Parameters

    Returns boolean

  • Description

    returns true if the current vector and the vector passed in as an argument are perpendicular

    Returns

    true if the current vector and the vector passed in as an argument are perpendicular

    Parameters

    Returns boolean

  • Description

    returns the length of the vector

    Returns

    the length of the vector

    Returns number

  • Description

    returns a new vector that is the current vector but with the opposite direction

    Returns

    a new vector that is the current vector but with the opposite direction

    Returns Vector

  • Description

    returns a new vector with the same direction as the current vector but with a length of 1

    Returns

    a new vector with the same direction as the current vector but with a length of 1

    Returns Vector

  • Description

    returns a new vector that is the current vector projected onto the vector passed in as an argument

    Returns

    a new vector that is the current vector projected onto the vector passed in as an argument

    Example

    const vector = new Vector([1,2,3])
    const vector2 = new Vector([1,1,1])
    vector.projectOn(vector2) // returns a new vector with the same direction as vector2 but with a length of 2
    vector.projectOn(vector2).length() // returns 2
    vector.projectOn(vector2).haveSameDirectionWith(vector2) // returns true
    vector.projectOn(vector2).isPerpendicularTo(vector2) // returns true

    Parameters

    Returns Vector

  • Description

    returns a new vector that is the current vector scaled by the scalar passed in as an argument

    Returns

    a new vector that is the current vector scaled by the scalar passed in as an argument

    Parameters

    • scalar: number

    Returns Vector

  • Description

    returns a new vector that is the current vector minus the vector passed in as an argument

    Returns

    a new vector that is the current vector minus the vector passed in as an argument

    Parameters

    • components: number[]

    Returns Vector

  • Description

    returns a new vector that is the current vector transformed by the matrix passed in as an argument

    Returns

    a new vector that is the current vector transformed by the matrix passed in as an argument

    Parameters

    Returns Vector

  • Description

    returns a new vector that is the current vector but with a length of the number passed in as an argument

    Returns

    a new vector that is the current vector but with a length of the number passed in as an argument

    Parameters

    • length: number

    Returns Vector

  • returns a matrix of combined vectors

    Returns

    a matrix of combined vectors

    Parameters

    Returns Matrix