vectorField normalise
- further to today's discussions, should add in a normalise() method to vectorField and GeometricFields.
Default implementation would be a no-op. For a specialised vectorField
would forward to calling vector::normalise on each entry. FieldFields - same thing.
@kuti expressed the wish to have an optional tolerance parameter. Which is ok, except that we would probably want to unroll the function calls to determine the mag directly (within the loop) instead of forwarding to vector::normalise for that.
Not really sure if we want to have a top-level normalise function (eg, taking a field and returning a tmp). Could get a bit weird, not sure we need it.
Main benefits:
- simpler to write ; Eg,
fld.normalise()
vs.field /= mag(fld)
- while not forgetting to handle divide by zero. Eg,
fld.normalise()
vs.field /= mag(fld) + VSMALL
- code efficiency. More efficient to loop over and re-assign the existing field instead of allocating a tmp (for the mag) adding VSMALL and then dividing (another tmp) to replace the original field.
Edited by Mark OLESEN