Field Calculus
2D
Gradient
v@v = 0;
for( int i=0; i<neighbourcount(0, @ptnum); i++ ){
int np = neighbour(0,@ptnum,i);
@v += normalize(@P - point(0,"P", np)) * point(0,"A", np);
}
Divergence
f@divergence = 0;
for( int i=0; i<neighbourcount(0, @ptnum); i++ ){
int np = neighbour(0,@ptnum,i);
float dot = dot(@v,normalize(point(0,"P", np) - @P) );
vector nv = point(0,"v", np);
@divergence += dot * length( nv );
}
@Cd = @divergence;