
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
simplevectorsjs
Advanced tools
SimpleVectorsJS is a library to make working with vectors in Node JS easy, including all standard vector operations and properties for n-dimension vectors
npm install simplevectorsjs
let { Vector, VectorConstants } = require("simplevectorsjs");
let a = new Vector(2, 0.5); //Create a new vector with components <-1, -1>
let b = new Vector();
b.fromMagnitudeAngle2D(10, Math.PI); //Set this vector from a magnitude and a direction (2D only)
let c = new Vector();
c.fromTwoPoints([0,0,0],[-2,2,1]); //Set this vector from two points
let d = a.add(b); //Add b to a
console.log("a+b: ", d.toString());
d = a.subtract(b); //Subtract b from a
console.log("a-b: ", d.toString());
d = b.multiply(5); //Multiply a by a scalar
console.log("5*b: ", d.toString());
d = a.unit(); //Get the unit vector
d = d.multiply(10); //And scale to 5
//OR, set the magnitude of the vector:
//d = a.getCopy(); //Get a copy of the vector
//d.magnitude = 5;
console.log("5*(a/|a|): ", d.toString());
d = c.cross(new Vector(-1,2,1));
console.log("c x <-1, 2, 1>: ", d.toString());
let e = a.dot(b);
console.log("a•b: ", e);
e = c.tripleScalarProduct(new Vector(1,2,0), new Vector(-2,0,1));
console.log("c•(<1,2,0> x <-2,0,1>): ", e);
e = a.scal(b); //Scalar projection of b onto a
console.log("Scal_a b: ", e);
d = a.proj(b); //Vector projection of b onto a
console.log("Vect_a b: ", d.toString());
e = b.angle(a); //Angle between a and b
console.log("Absolute angle between a and b: ", e);
e = a.angle(VectorConstants.D2.i); //Angle between b and positive x-axis
console.log("Absolute angle between a and positive x-axis (i): ", e);
console.log("Magnitude of a: ", a.magnitude);
console.log("Number of components in a: ", a.size);
console.log("Is unit vector? a/|a|: ", a.multiply(1/a.magnitude).isUnit());
console.log("Is equal vector? a/|a|==a: ", a.unit().isEqual(a));
Copyright 2020 Alex Mous
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
numbernumbernumberVectorVectorVectorVectorVectorVectornumbernumbernumbernumberstringbooleanbooleanVectorConstantsSimplevectors is a library to make working with vectors in Node JS easy, including all standard vector operations and properties for n-dimension vectors
Kind: static class of Simplevectors
numbernumbernumberVectorVectorVectorVectorVectorVectornumbernumbernumbernumberstringbooleanbooleanVector class
| Param | Type | Description |
|---|---|---|
| ...components | number | Components of the vector to construct |
numberGet the magnitude of the vector
Kind: static property of Vector
numberGet the number of components of the vector
Kind: static property of Vector
numberSet the new magnitude
Kind: static property of Vector
Set this vector from magnitude and angle from positive x-axis in 2D
Kind: inner method of Vector
| Param | Type | Description |
|---|---|---|
| magnitude | number | Magnitude |
| angle | number | Angle (radians) |
Set this vector from the difference between two points
Kind: inner method of Vector
| Param | Type | Description |
|---|---|---|
| point1 | Array.<number> | Point 1 (array of distance in each dimension) |
| point2 | Array.<number> | Point 2 (same number of dimensions as Point 1) |
VectorUnit vector
Kind: inner method of Vector
Returns: Vector - The unit vector
VectorScalar multiplication
Kind: inner method of Vector
Returns: Vector - Scaled vector
| Param | Type | Description |
|---|---|---|
| k | number | Scalar k to multiply vector by |
VectorAdd vect to this vector
Kind: inner method of Vector
Returns: Vector - New vector
| Param | Type | Description |
|---|---|---|
| vect | Vector | Vector to add to this |
VectorSubtract vect from this vector
Kind: inner method of Vector
Returns: Vector - Difference between this and vect
| Param | Type | Description |
|---|---|---|
| vect | Vector | Vector to subtract from this |
VectorCross product (3D vectors) of vect with this vector (this x vect)
Kind: inner method of Vector
Returns: Vector - The cross product vector
| Param | Type | Description |
|---|---|---|
| vect | Vector | Vector to do a cross product with |
Vector projection of vect onto this vector
Kind: inner method of Vector
| Param | Type |
|---|---|
| vect | Vector |
VectorGet a copy of this vector
Kind: inner method of Vector
Returns: Vector - A copy of this vector
numberDot product
Kind: inner method of Vector
Returns: number - The dot product of the two vectors
| Param | Type | Description |
|---|---|---|
| vect | Vector | Vector to do a dot product with |
numberGet the triple scalar product of this vector, vect1 and vect2 (this•(vect1 x vect2))
Kind: inner method of Vector
Returns: number - Triple scalar product
| Param | Type | Description |
|---|---|---|
| vect1 | Vector | First vector |
| vect2 | Vector | Second vector |
numberAngle between this vector and vect (0 <= angle <= PI)
Kind: inner method of Vector
Returns: number - Angle (0 <= theta <= PI)
| Param | Type | Description |
|---|---|---|
| vect | Vector | Vector to calculate angle between |
numberScalar projection of vect onto this vector
Kind: inner method of Vector
Returns: number - Projection
| Param | Type |
|---|---|
| vect | Vector |
stringGet the string representation of the vector
Kind: inner method of Vector
Returns: string - Vector as a string
booleanIs this a unit vector?
Kind: inner method of Vector
booleanIs this the same as vect?
Kind: inner method of Vector
| Param | Type |
|---|---|
| vect | Vector |
VectorConstantsKind: static constant of Simplevectors
FAQs
SimpleVectorsJS is a library to make working with vectors in Node JS easy, including all standard vector operations and properties for n-dimension vectors
The npm package simplevectorsjs receives a total of 0 weekly downloads. As such, simplevectorsjs popularity was classified as not popular.
We found that simplevectorsjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.