Support for vector calculus in JavaScript.
The following methods are accessible through the Math.vc
namespace:
add(A,B)
sub(A,B)
mul(A,k)
dotProduct(A,B)
crossProduct(A,B)
outerProduct(A,B)
kroneckerProduct(A,B)
angle(A,B)
projection(A,B)
arePerpendicular(A,B)
areParallel(A,B)
length(V)
normalize(V)
Plus the following differential methods:
gradient(f)
divergence(F)
curl(F)
laplacian(f)
vectorLaplacian(F)
Adds two vectors.
Subtracts two vectors.
Multiplies a vector by a scalar value.
The dot product of two vectors.
The cross product of two vectors.
The outer product of two vectors.
The Kronecker product of two vectors.
Returns an angle between two vectors.
Projects vector A on vector B.
Checks if two vectors are perpendicular.
Checks if two vectors are parallel.
Returns a length of a vector.
Performs normalization of a vector.
- input:
$f: \Bbb{R}^3 \to \Bbb{R}$ - output:
$\Bbb{R}^3$
- input:
$F: \Bbb{R}^3 \to \Bbb{R}^3$ - output:
$\Bbb{R}$
- input:
$F: \Bbb{R}^3 \to \Bbb{R}^3$ - output:
$\Bbb{R}^3$
- input:
$f: \Bbb{R}^3 \to \Bbb{R}$ - output:
$\Bbb{R}$
- input:
$F: \Bbb{R}^3 \to \Bbb{R}^3$ - output:
$\Bbb{R}^3$
- a scalar field
$f: \Bbb{R}^3 \to \Bbb{R}$ receives three arguments ($x,y,z$ ) and return a scalar value - a vector field
$\Bbb{R}^3$ is an object with the following three properties:dx
,dy
anddz
To get the following gradient:
we shall write:
const f = (x,y,z) => x*x + y*y + z*z;
const grad = Math.vc.gradient(f);
grad(1,2,3)
// {dx: 2, dy: 4, dz: 6 }
To get the following curl:
we shall write:
const F = (x,y,z) => ({
dx: -y,
dy: x,
dz: 0
});
const curl = Math.vc.curl(F);
curl(1,1,1)
// {dx: 0, dy: 0, dz: 2}