pointInHexa

pyvsim.Utils.pointInHexa(p, hexapoints)[source]

Taking a set of points defining a hexahedron in the conventional order, this function tests of the point is inside this hexahedron by:

For each face:
  • calculate normal pointing outwards
  • verify if point is “behind” the plane defined by the face
Parameters :

p : numpy.ndarray \((N,3)\)

List of points to be tested

hexapoints : numpy.ndarray \((8,3)\)

List of points defining an hexahedron, must obey the conventional order of defining hexas. Also works in the case hexa has negative volume (this was made especifically for cases when laser sheet is reflected)

Returns :

1 :

if points lies inside the hexahedron

0 :

otherwise

Examples

>>> hexapoints = np.array([[0,0,0], 
...                        [0,1,0], 
...                        [0,1,1], 
...                        [0,0,1], 
...                        [1,0,0], 
...                        [1,1,0], 
...                        [1,1,1], 
...                        [1,0,1]])
>>> p = np.array([[  0,  0,  0], 
...               [0.5,0.5,0.5], 
...               [  2,  0,  0]])
>>> pointInHexa(p, hexapoints)
array([ 0.,  1.,  0.])

This Page