VLength
Computes the length of the provided vector
See also: VDistance
Description
VLength computes the length of the provided vector as the square root of the sum of the squares of its components. It works on input dimensions 1-4. In the 1D case it returns the absolute value of the input.
Supported Rates: frame, shape, pixel
Class Methods
VLength.fr(v)
VLength.sr(v)
VLength.pr(v)
Make a VLength VGen at requested rate.
Arguments
v
The input vector.
Returns:
The length of the vector.
dimensions
input |
output |
1 |
1 |
2 |
1 |
3 |
1 |
4 |
1 |
Examples
(
// This demo shows a graph of the magnetic flux density around a
// dipole magnet pointing along the y axis. It is a 3D radial
// function and uses the Length operator to compute the radius
// at each pixel, which is an input to the function (see
// https://en.wikipedia.org/wiki/Magnetic_dipole), as well as
// the magnitude of the magnetic flux vector at each point,
// to generate the black and white image.
~k = ScinthDef.new(\k, {
var pos = VNormPos.pr;
var r = VVec3.pr(VX.pr(pos), VY.pr(pos), 0.0);
var magR = VLength.pr(r);
var m = VVec3.pr(0.0, 0.1, 0.0);
var flux = VCross.pr(m, r) / magR.cubed;
VBWOut.pr(VClamp.pr(VLength.pr(flux), 0.0, 1.0));
}).add;
)
(
~t = Scinth.new(\k);
)
Last modified July 28, 2020: Update for a 0.0.7 Scintillator release (#5) (0177d81)