isonormals

Compute normal vectors to an interpolated isosurface.

Syntax

[vn] = isonormals(x, y, z, val, vert)

[vn] = isonormals(val, vert)

[vn] = isonormals(..., 'negate')

Inputs

x, y, z
Coordinate vectors from which to construct a grid. The vectors are typically generated from meshgrid, but can also be the simple vectors. If omited, the value default to [x,y,z] = meshgrid(1:l, 1:m, 1:n) where [l,m,n] = size(val).
Type: double
Dimension: vector | matrix
val
An LxMxN matrix containing isosurface geometry function values.
Type: double
Dimension: matrix
vert
The vertices at which to compute normal vectors. Each row contains the coordinates of a vertex. The function is so named because the vertices typically lie on an isosurface.
Type: double
Dimension: matrix

Outputs

vn
The matrix of normal vectors. There is one row for each row of vert.

Comments

The function approximates the normal vector at each vertex from the gradient of a trilinear interpolation function over the neighboring grid points.

The output normal vectors are the negatives of the gradients, so that they point downward relative to the isosurface values. The sign can be reversed using the 'negative' input.