Number of coordinates: 2 in the plane, 3 in space.
ASCIIMath rendering of the current state (terminal output, not chainable).
Euclidean norm, as a decimal number.
Square of the norm, as an exact fraction.
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.
LaTeX rendering of the current state (terminal output, not chainable).
Third coordinate. Setting it accepts a fraction, a number or a string.
Angle between two vectors, in degrees by default.
Optionalsharp: boolean
return the acute angle (absolute value of the dot product)
Optionalradian: boolean
return radians instead of degrees
Returns a deep copy of the raw coordinate array. Unlike clone(), returns a Fraction[], not a TupleN instance.
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.
True when both vectors are parallel (one is a multiple of the other).
True when the vectors are perpendicular: their dot product is zero.
True for the vector (1, 0, ...), which one produces.
True when every coordinate is zero.
Set the vector to (1, 0, ...).
Change the sign of every coordinate.
Replace the coordinates with numbers, a string, a vector or a point, or with the vector from one point to another.
Scale the vector to the smallest integer coordinates with no common divisor, and make the first coordinate positive. The direction is kept.
Add the given values to the coordinates, one per coordinate.
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.
Set every coordinate to zero.
StaticasText form of a vector from already written coordinates: asDisplay("x", "y") is ((x,y)).
StaticasLaTeX form of a vector from already written coordinates.
StaticfromBuild the linear combination written by a polynom: fromPolynom("2a-b", {a: "(1;0)", b: "(0;1)"}) is (2;-1).
the vector (or its string) of each variable.
StaticfromProtected StaticparseStrips optional outer parentheses, splits on , ; or space, and returns the parsed Fraction array.
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 vectorAB.Example