Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector

Base class to work with vector quantities.

abstract

Hierarchy

Implements

Index

Properties

Abstract X

X: function

Type declaration

quantity

quantity: "vector" = "vector"

Abstract type

type: "constant" | "variable" | "expression"

Methods

Abstract add

  • Adds two Vectors together. If this and that are both constants then vectorially adds the two and returns a new Vector.Constant object otherwise creates an Expression out of them and returns the same.

    Parameters

    • that: Vector

      The scalar to add this with.

    Returns Vector

    The result of algebraic addition.

Abstract cross

  • Evaluates the vector product of this and that. If both are constants then numerically computes the product and returns a Vector.Constant object otherwise creates an Expression out of them and returns the same.

    Parameters

    • that: Vector

      The scalar to subtract from this.

    Returns Vector

    The vector product of this and that.

Abstract dot

  • Evaluates the scalar product of this and that. If both are constants then numerically computes the product and returns a Scalar.Constant object otherwise creates an Expression out of them and returns the same.

    Parameters

    • that: Vector

      The scalar to subtract from this.

    Returns Scalar

    The inner product of this and that.

Abstract scale

  • Scales, or multiplies the "size" (magnitude) of, this vector by given amount. If this and k are both constants then numerically calculates the scaled vector otherwise creates an Expression out of them and returns the same.

    Parameters

    Returns Vector

    The scaled vector.

Abstract sub

  • Subtracts that from this. If this and that are both constants then vectorially subtracts one from the other and returns a new Vector.Constant object otherwise creates an Expression out of them and returns the same.

    Parameters

    • that: Vector

      The scalar to subtract from this.

    Returns Vector

    The result of algebraic subtraction.

Static constant

  • Creates a new Vector.Constant object from a list of numbers if it has not been created before. Otherwise just returns the previously created object.

    This is the recommended way of creating Vector.Constant objects instead of using the constructor.

    Parameters

    • value: number[]

      The fixed value the Vector.Constant is supposed to represent.

    Returns Constant

  • Defines a named Vector.Constant object from a list of numbers if it has not been created before. Otherwise just returns the previously created object.

    This is the recommended way of creating named Vector.Constant objects instead of using the constructor.

    throws

    Throws an error if a Vector.Constant with the same name has been defined previously.

    Parameters

    • value: number[]

      The fixed value the Vector.Constant is supposed to represent.

    • name: string

      The string with which this object is identified.

    Returns Constant

  • Creates a new Vector.Constant object from a list of Scalar.Constant objects if it has not been created before. Otherwise just returns the previously created object.

    This is the recommended way of creating Vector.Constant objects instead of using the constructor.

    Parameters

    Returns Constant

  • Defines a named Vector.Constant object from a list of Scalar.Constant objects if it has not been created before. Otherwise just returns the previously created object.

    This is the recommended way of creating named Vector.Constant objects instead of using the constructor.

    throws

    Throws an error if a Vector.Constant with the same name has been defined previously.

    Parameters

    • value: Constant[]

      The fixed value the Vector.Constant is supposed to represent.

    • name: string

      The string with which this object is identified.

    Returns Constant

  • Returns a previously declared named Vector.Constant object.

    Parameters

    • name: string

      The name of the named Vector.Constant object to be retrieved.

    Returns Constant

Static mag

  • Computes the magnitude of a constant vector numberically.

    Parameters

    Returns Constant

    The Scalar magnitude of the given Vector.

  • Computes the magnitude of a given vector. If A vector is a constant vector then numerically calculates the magnitude otherwise creates a scalar Expression and returns the same.

    Parameters

    Returns Expression

    The Scalar magnitude of the given Vector.

Static unit

Static variable

  • Creates a new Vector.Variable object if it has not been created before. Otherwise just returns the previously created object.

    This is the recommended way of creating Vector.Variable objects instead of using the constructor.

    Parameters

    • name: string

      The string with which this object will be identified.

    Returns Variable

  • Creates a Vector.Variable object from an array. The array may contain known scalar constants and, for the components yet unknown, __. Passing __ as an element of the value array automatically gets interpreted as having a variable at that index. This allows for creation of vectors whose few components are known before hand and the rest are not. For example,

    const A = Vector.variable("A", [1, __, 4, __, 2]);
    console.log(A);

    This line of code will create a vector whose 2nd and 4th components are Scalar.Variable objects and the remaining will be Scalar.Constant objects.

    This is the recommended way of creating Vector.Variable objects instead of using the constructor.

    Parameters

    • name: string

      The name with which the Vector.Variable is going to be identified.

    • value: (undefined | number | Constant)[]

      The array containing the values with which to initialise the vector variable object.

    Returns Variable

Generated using TypeDoc