PiMath API
    Preparing search index...

    Class Vector

    A vector of the plane or of space, with exact coordinates. Built from numbers (new Vector(3, 4)), from a string ("(3;4)"), from another vector or point, or from two points: new Vector(A, B) is the vector AB.

    new Vector(new Point(1, 2), new Point(4, 6)).display // "((3,4))"
    

    Hierarchy (View Summary)

    Implements

    Index
    • get dimension(): number

      Number of coordinates: 2 in the plane, 3 in space.

      Returns number

    • get norm(): number

      Euclidean norm, as a decimal number.

      Returns number

    • get onChange(): (() => void) | undefined

      Function called when a coordinate is set through x, y or z, or when the tuple is zeroed. Triangle uses it to refresh its remarkable lines.

      Returns (() => void) | undefined

    • set onChange(value: (() => void) | undefined): void

      Parameters

      • value: (() => void) | undefined

      Returns void

    • Angle between two vectors, in degrees by default.

      Parameters

      • V: Vector
      • Optionalsharp: boolean

        return the acute angle (absolute value of the dot product)

      • Optionalradian: boolean

        return radians instead of degrees

      Returns number

      if one of the vectors is the zero vector (the angle is undefined)

    • Copy the mathematical state of another instance into this (display state is NOT transferred — the receiver keeps its own formatting). Entry point used when constructing/parsing from a same-type input. Distinct from clone. Classes without a real implementation throw NotImplementedError.

      Parameters

      Returns this

    • Rotates 90° to obtain a perpendicular vector: (x, y) → (y, −x).

      Returns this

      if the vector is not 2-dimensional

    • Replace the coordinates with numbers, a string, a vector or a point, or with the vector from one point to another.

      Parameters

      Returns this

      if the arguments are not valid.

      if two points have different dimensions.

      if a value is not a number.

    • Change the number of coordinates: new ones are zero, extra ones are removed.

      Parameters

      • value: number = 2

      Returns this

      if value is less than 2.

    • Scale the vector to the smallest integer coordinates with no common divisor, and make the first coordinate positive. The direction is kept.

      Returns this

    • Divide by the norm. The norm is a decimal number, so the result is exact only when it is rational. The zero vector is left as it is.

      Returns this

    • Text form of a vector from already written coordinates: asDisplay("x", "y") is ((x,y)).

      Parameters

      • ...values: string[]

      Returns string

    • LaTeX form of a vector from already written coordinates.

      Parameters

      • ...values: string[]

      Returns string

    • Build the linear combination written by a polynom: fromPolynom("2a-b", {a: "(1;0)", b: "(0;1)"}) is (2;-1).

      Parameters

      Returns Vector

      if the polynom has a constant term, a term that is not linear, or a variable without vector.

      if the vectors have different dimensions.

    • Accepts ((x,y,...)), (x;y;...), or x,y,... format.

      Parameters

      • value: string

      Returns Vector

      if fewer than 2 components are found

    • Strips optional outer parentheses, splits on , ; or space, and returns the parsed Fraction array.

      Parameters

      • value: string

      Returns Fraction[]

      if fewer than 2 components are found.