Polygon#

class pinnx.geometry.Polygon(vertices)[source]#

Simple polygon.

Parameters:

vertices – The order of vertices can be in a clockwise or counterclockwise direction. The vertices will be re-ordered in counterclockwise (right hand rule).

boundary_normal(x)[source]#

Compute the unit normal at x for Neumann or Robin boundary conditions.

Parameters:

x – A 2D array of shape (n, dim), where n is the number of points and dim is the dimension of the geometry.

inside(x)[source]#

Check if x is inside the geometry (including the boundary).

Parameters:

x – A 2D array of shape (n, dim), where n is the number of points and dim is the dimension of the geometry.

Returns:

A boolean array of shape (n,) where each element is True if the point is inside the geometry.

on_boundary(x)[source]#

Check if x is on the geometry boundary.

Parameters:

x – A 2D array of shape (n, dim), where n is the number of points and dim is the dimension of the geometry.

Returns:

A boolean array of shape (n,) where each element is True if the point is on the boundary.

random_boundary_points(n, random='pseudo')[source]#

Compute the random point locations on the boundary.

random_points(n, random='pseudo')[source]#

Compute the random point locations in the geometry.

Parameters:
  • n – The number of points.

  • random – The random distribution. One of the following: “pseudo” (pseudorandom), “LHS” (Latin hypercube sampling), “Halton” (Halton sequence), “Hammersley” (Hammersley sequence), or “Sobol” (Sobol sequence

uniform_boundary_points(n)[source]#

Compute the equi-spaced point locations on the boundary.

Parameters:

n – The number of points.