in3Utils.geoTrans.getNormalMesh

getNormalMesh(dem, num=4)[source]

Compute normal to surface at grid points

Get the normal vectors to the surface defined by a DEM. Either by adding the normal vectors of the adjacent triangles for each points (using 4, 6 or 8 adjacent triangles). Or use the next point in x direction and the next in y direction to define two vectors and then compute the cross product to get the normal vector

  • moved from com1DFA/DFAtools

Normal computation on rectangular grid explanation for num parameter 4 triangles method 6 triangles method 8 triangles method +—-U—-UR—+—+–… +—-+—-+—-+—+–… +—-+—-+—-+—+–… | /|\ | /| | /| 2 /| /| |\ 2 | 3 /| /| Y | / | | / | | / | / | / | | | / | / | ^ | / | | / | / | / | / | / | / | | / | / | / | |/ 1 | 2 \|/ |/ |/ 1 |/ 3 |/ |/ | 1 \|/ 4 |/ |/ | +----P----L----+---+--... +----*----+----+---+--... +----*----+----+----+--... +-----> X |\ 4 | 3 /| /| | 6 /| 4 /| /| | 8 /|\ 5 | /| | | / | / | | / | / | / | | / | | / | | | / | / | / | / | / | / | / | / | | / | / | |/ |/ |/ |/ 5 |/ |/ |/ |/ 7 | 6 \|/ |/ +----+----+----+---+--... +----+----+----+---+--... +----+----+----+---+--... | /| /| /| | /| /| /| | /| /| /| 4 Options available : -1: simple cross product method (with the diagonals P-UR and U-L)

-4: 4 triangles method -6: 6 triangles method -8: 8 triangles method

Parameters
  • dem (dict) –

    header :

    dem header (cellsize, ncols, nrows)

    rasterData2D numpy array

    elevation at grid points

  • num (int) – chose between 4, 6 or 8 (using then 4, 6 or 8 triangles) or 1 to use the simple cross product method (with the diagonals)

Returns

dem

dem dict updated with:
Nx: 2D numpy array

x component of the normal vector field on grid points

Ny: 2D numpy array

y component of the normal vector field on grid points

Nz: 2D numpy array

z component of the normal vector field on grid points

outOfDEM: 2D boolean numpy array

True if the cell is out the dem, False otherwise

Return type

dict