tspart.voronoi
Module Contents
Functions
|
Polygon rasterization (scanlines). |
Polygon outline rasterization (scanlines). |
|
|
Given an ordered set of vertices V describing a polygon, |
Given an ordered set of vertices V describing a polygon, |
|
|
Given an ordered set of vertices V describing a polygon, |
|
|
|
|
|
Given a set of point and a density array, return the set of weighted |
|
|
|
Return n points distributed over [xmin, xmax] x [ymin, ymax] |
|
|
|
- tspart.voronoi.rasterize(V)
Polygon rasterization (scanlines).
Given an ordered set of vertices V describing a polygon, return all the (integer) points inside the polygon. See http://alienryderflex.com/polygon_fill/
Parameters:
- V(n,2) shaped numpy array
Polygon vertices
- tspart.voronoi.rasterize_outline(V)
Polygon outline rasterization (scanlines).
Given an ordered set of vertices V describing a polygon, return all the (integer) points for the polygon outline. See http://alienryderflex.com/polygon_fill/
Parameters:
- V(n,2) shaped numpy array
Polygon vertices
- tspart.voronoi.weighted_centroid_outline(V, P, Q)
Given an ordered set of vertices V describing a polygon, return the surface weighted centroid according to density P & Q.
P & Q are computed relatively to density: density_P = density.cumsum(axis=1) density_Q = density_P.cumsum(axis=1)
This works by first rasterizing the polygon and then finding the center of mass over all the rasterized points.
- tspart.voronoi.uniform_centroid(V)
Given an ordered set of vertices V describing a polygon, returns the uniform surface centroid.
- tspart.voronoi.weighted_centroid(V, D)
Given an ordered set of vertices V describing a polygon, return the surface weighted centroid according to density D.
This works by first rasterizing the polygon and then finding the center of mass over all the rasterized points.
- tspart.voronoi.in_box(points, bbox)
- tspart.voronoi.voronoi(points, bbox)
- tspart.voronoi.centroids(points, density, density_P=None, density_Q=None)
Given a set of point and a density array, return the set of weighted centroids.
- tspart.voronoi.normalize(D)
- tspart.voronoi.initialization(n, D)
Return n points distributed over [xmin, xmax] x [ymin, ymax] according to (normalized) density distribution.
- with xmin, xmax = 0, density.shape[1]
ymin, ymax = 0, density.shape[0]
The algorithm here is a simple rejection sampling.
- tspart.voronoi.stipple_image(grayscale_array, points=5000, iterations=50, logging=True)
- tspart.voronoi.stipple_image_multi(grayscale_arrays, points=5000, iterations=50, logging=True)