permaviss.covers.cubical_cover

Functions

corners_hypercube(point_cloud) Returns maximum and minimum corners of hypercube containing point_cloud.
generate_cover(max_div, overlap, point_cloud) Divides a point cloud into a cubical cover.
intersection_covers(points_IN, simplex) Computes the points in the intersection specified by a nerve simplex.
nerve_hypercube_cover(div) Generates the nerve of an hypercube covering.
next_hypercube(pos, div) Jumps to next hypercube in cubical cover
permaviss.covers.cubical_cover.corners_hypercube(point_cloud)[source]

Returns maximum and minimum corners of hypercube containing point_cloud.

Parameters:point_cloud (Numpy Array) – Coordinates of point data. Each row corresponds to a point.
Returns:min_corner, max_corner – Minimum and maximum corners of containing hypercube.
Return type:Numpy Array, Numpy Array

Example

>>> from permaviss.sample_point_clouds.examples import random_cube
>>> point_cloud = random_cube(5,2)
>>> point_cloud
array([[-0.30392908, -0.40559307],
       [ 0.4736051 , -0.28257937],
       [-0.41760472, -0.30445089],
       [-0.02406966,  0.001455  ],
       [-0.28425041, -0.11212227]])
>>> min_corner, max_corner = corners_hypercube(point_cloud)
>>> min_corner
array([-0.41760472, -0.40559307])
>>> max_corner
array([ 0.4736051,  0.001455 ])
permaviss.covers.cubical_cover.generate_cover(max_div, overlap, point_cloud)[source]

Divides a point cloud into a cubical cover.

Receives a point cloud point_cloud in R^n and returns it divided into cubes and their respective intersections. It also generates the nerve of the covering.

Parameters:
  • max_div (int) – Number of divisions on the maximum side of point_cloud
  • overlap (float) – Overlap between adjacent hypercubes.
  • point_cloud (Numpy Array) – Each row contains the coordinates of a point
Returns:

  • divided_point_cloud (list(list(Numpy Array 2D))) – Point cloud coordinates indexed by nerve. The i entry contains the point cloud coordinates indexed by the i simplices of the nerve. That is, the first entry contains the coordinates contained in hypercubes. The second entry the coordinates of points in double intersections of hypercubes. And so on.
  • points_IN (list(list(Numpy Array 1D))) – Identification Numbers (IN) of points in regions indexed by nerve. That is, this is the same as divided_point_cloud but storing IN instead of coordinates.
  • nerve (list(Numpy Array)) – The nerve of the hypercube cover.

Example

>>> point_cloud = circle(5, 1)
>>> max_div = 2
>>> overlap = 0.5
>>> divided_point_cloud, points_IN, nerve = generate_cover(max_div,
... overlap, point_cloud)
>>> divided_point_cloud[0]
[array([[-0.80901699, -0.58778525],
       [ 0.30901699, -0.95105652]]), array([[ 0.30901699,  0.95105652],
       [-0.80901699,  0.58778525]]), array([[ 1.        ,  0.        ],
       [ 0.30901699, -0.95105652]]), array([[ 1.        ,  0.        ],
       [ 0.30901699,  0.95105652]])]
>>> divided_point_cloud[1]
[array([], shape=(0, 2), dtype=float64), array([[ 0.30901699,
-0.95105652]]), array([], shape=(0, 2), dtype=float64), array([],
shape=(0, 2), dtype=float64), array([[ 0.30901699,  0.95105652]]),
array([[ 1.,  0.]])]
>>> points_IN[0]
[array([3, 4]), array([1, 2]), array([0, 4]), array([0, 1])]
>>> points_IN[1]
[array([], dtype=float64), array([4]), array([], dtype=float64),
array([], dtype=float64), array([1]), array([0])]
>>> nerve[0]
4
>>> nerve[1]
array([[ 0.,  1.],
       [ 0.,  2.],
       [ 1.,  2.],
       [ 0.,  3.],
       [ 1.,  3.],
       [ 2.,  3.]])
>>> nerve[2]
array([[ 0.,  1.,  2.],
       [ 0.,  1.,  3.],
       [ 0.,  2.,  3.],
       [ 1.,  2.,  3.]])
>>> nerve[3]
array([[ 0.,  1.,  2.,  3.]])
permaviss.covers.cubical_cover.intersection_covers(points_IN, simplex)[source]

Computes the points in the intersection specified by a nerve simplex.

Parameters:
  • points_IN (list(list(Numpy Array 1D))) – Identification Numbers (IN) of points in covering hypercubes.
  • simplex (Numpy Array) – Simplex in nerve which specifies intersection between hypercubes.
Returns:

points_IN_intersection – IN of points in the intersection specified by simplex.

Return type:

list(int)

Example

>>> import numpy as np
>>> points_IN = [np.array([0,3,5]),np.array([0,1]), np.array([1,5])]
>>> simplex = np.array([0,1])
>>> intersection_covers(points_IN, simplex)
[0]
permaviss.covers.cubical_cover.nerve_hypercube_cover(div)[source]

Generates the nerve of an hypercube covering.

Given an array of divisions of an hypercube cover, this returns the nerve.

Parameters:div (Numpy Array) – 1D array of divisions per dimension.
Returns:nerve – Nerve associated to hypercube covering.
Return type:list(Numpy Array)

Example

Nerve for three dimensional covering. There are 6 hypercubes and the divisions per dimension are given as 1 x 3 x 2.

>>> div = [1,3,2]
>>> nerve = nerve_hypercube_cover(div)
>>> nerve[0]
6
>>> nerve[1]
array([[ 0.,  1.],
       [ 0.,  2.],
       [ 1.,  2.],
       [ 0.,  3.],
       [ 1.,  3.],
       [ 2.,  3.],
       [ 2.,  4.],
       [ 3.,  4.],
       [ 2.,  5.],
       [ 3.,  5.],
       [ 4.,  5.]])
>>> nerve[2]
array([[ 0.,  1.,  2.],
       [ 0.,  1.,  3.],
       [ 0.,  2.,  3.],
       [ 1.,  2.,  3.],
       [ 2.,  3.,  4.],
       [ 2.,  3.,  5.],
       [ 2.,  4.,  5.],
       [ 3.,  4.,  5.]])
>>> nerve[3]
array([[ 0.,  1.,  2.,  3.],
       [ 2.,  3.,  4.,  5.]])
>>> nerve[4]
[]
permaviss.covers.cubical_cover.next_hypercube(pos, div)[source]

Jumps to next hypercube in cubical cover

Parameters:
  • pos (list) – List of integer values specifying the position of the current hypercube. This is edited to the next hypercube.
  • div (list) – List of integer values specifying how many hypercubes divide each dimension.

Example

>>> pos = [1,1,1]
>>> div = [3,3,2]
>>> next_hypercube(pos, div)
>>> pos
[1, 2, 0]