VDot
VGen to compute vector dot product
See also: VCross
Description
Computes the dot product of two vectors u and v.
Supported Rates: frame, shape, pixel
Class Methods
VDot.fr(u, v)
VDot.sr(u, v)
VDot.pr(u, v)
Make a VDot VGen at requested rate.
Arguments
u
First vector input to cross product.
v
Second vector input to cross product.
Returns:
The dot product of u and v
Dimensions
input |
output |
1, 1 |
1 |
2, 2 |
1 |
3, 3 |
1 |
4, 4 |
1 |
Examples
// Demonstration of the use of dot product identity
// a dot b = mag(a) * mag(b) * cos(theta) to compute
// the angle between the x axis and the fragment
// position. This is compared against the position
// of a flower radial function and that drives the
// output value.
(
~flower = ScinthDef.new(\flower, { |l=5, k=1|
var pos = VNormPos.pr;
var posNorm = VNorm.pr(pos);
var xaxis = VVec2.pr(1.0, 0.0);
var theta = VDot.pr(posNorm, xaxis).acos;
var r = abs(sin(theta * l)) * k;
VBWOut.pr((1.0 - VDistance.pr(pos, r * posNorm)).abs);
}).add;
)
(
~k = Scinth.new(\flower);
)
Last modified July 28, 2020: Update for a 0.0.7 Scintillator release (#5) (0177d81)