polynomials_on_simplices.geometry.mesh.point_clouds module

Point cloud operations.

embed_point_cloud_in_rn(points, n)[source]

Embed an m-dimensional point cloud in \(\mathbb{R}^n, m < n\) by adding zeros for the missing coordinates.

Parameters:
  • points (Numpy array) – Points in the point cloud (num points by m array).
  • n (int) – Dimension of the space we want to embed in.
Returns:

The same point cloud embedded in \(\mathbb{R}^n\).

Return type:

Numpy array

Examples

>>> embed_point_cloud_in_rn(np.array([[0, 0], [1, 1]]), 3)
array([[0., 0., 0.],
       [1., 1., 0.]])
embed_point_in_rn(point, n)[source]

Embed an m-dimensional point in \(\mathbb{R}^n, m < n\) by adding zeros for the missing coordinates.

Parameters:
  • point (Numpy array) – Point (m:d vector).
  • n (int) – Dimension of the space we want to embed in.
Returns:

The same point embedded in \(\mathbb{R}^n\).

Return type:

Numpy array

Examples

>>> embed_point_in_rn(np.array([1, 1]), 3)
array([1., 1., 0.])
mean(points)[source]

Compute the mean, or centroid, of a point cloud in \(\mathbb{R}^m\).

\[\frac{1}{N} \sum_{i = 1}^N x_i,\]

where N is the number of points in the point cloud.

Parameters:points (Numpy array) – Points in the point cloud (N by m array).
Returns:Mean of the point cloud along each axis (length m array).
Return type:Numpy array

Examples

>>> mean(np.array([1.0, 3.0, 5.0]))
3.0
>>> mean(np.array([[1.0, 2.0], [3.0, 4.0]]))
array([2., 3.])
median(points)[source]

Compute the median of a point cloud in \(\mathbb{R}^m\).

The i:th entry of the median is the median of the i:th component of the points in the point cloud.

Parameters:points (Numpy array) – Points in the point cloud (num points by m array).
Returns:Median of the point cloud along each axis (length m array).
Return type:Numpy array

Examples

>>> median(np.array([1.0, 3.25, 5.0]))
3.25
>>> median(np.array([[1.0, 2.0], [3.0, 4.0]]))
array([2., 3.])
principal_component_axis(points)[source]

Get the principal component axis of a point cloud in \(\mathbb{R}^m\).

The principal component axis is the direction in which the point cloud is most spread out, i.e. the unit vector w which maximizes

\[\sum_{i = 1}^N \langle x_i - \bar{x}, w \rangle,\]

where N is the number of points in the point cloud and \(\bar{x}\) is the mean of the point cloud.

Parameters:points (Numpy array) – Points in the point cloud (N by m array).
Returns:Principal component axis of the point cloud (length m array).
Return type:Numpy array