Get Vertices¶
Methods for obtaining or generating vertices to iterate.
Todo
There is a method for creating vertices from a picture, but it does not work properly. On has to use the right pixel distance for the points an hope the picture has high enough resolution. This might need to be a project on it’s own.
-
get_vertices.make_ellipse(a=40.0, b=20.0, tilt=-0.5235987755982988)¶ Create the vertices for a ellipse or circle.
If a mathematical correct ellipse or circle is necessary, this method will create the vertices. It generates a ellipse with two radii, a and b. If a and b are equal a circle is generated. It is also possible to tilt the ellipse by some portion of pi.
Parameters: n: int, optional
Number of vertices.
a: double, optional
First radius of the ellipse.
b: double, optional
Second radius of the ellipse.
Returns: Numpy array
-
get_vertices.make_rectangle(a=400, b=40)¶ Generate a rectangle curve.
The rectangle is generated with two side lengths a and b. If both are the same a square is produced.
Parameters: n: int, optional
Number of points used in the rectangle
a: int, optional
First side length in pixel.
b: int, optional
Second side length in pixel.
Returns: numpy array:
Vertices of shape (n,2)
-
get_vertices.shift()¶ Shift the center of mass to (0,0)
-
get_vertices.load_example()¶ Load an example file or generate example with CM (0,0).
Options for name are:
- spiral
- bohne
- some_form
- ellipse
- circle
- square
- rectangle
Raises: Name Error
If name is not a example.
-
get_vertices.get_next_vertex()¶ Check where the next vertex sits on the curve and return it.
It does not care how many vertices are on the edge of the square it checks, it returns all of theme.
Parameters: data: numpy array
Data array with the part of the curve, that is being evaluated
Returns: touple
Coordinates of the next vertex
-
get_vertices.get_vertices(N)¶ Generate a list of vertices from an image.
The input data is an numpy array of equal dimensions (n,n) and a distance between the vertices. The data is scanned for a pixel that is at max value, which is the starting point. Afterwards a square is put around that point with the dimensions specified by N. The functions get_next_vertex is called and produces the next vertices. The one with the larges distance to the last one is used for the next iteration and added to the others. If the last vertex sits close to the first vertex the iteration if over. A maximum of 10000 vertices is generated, because the curve might loop on its own and become longer than it should.#
Parameters: data: numpy array
Array with shape (n,n) of the image to be sampled. The curve should be at max value, while the rest is at min value.
N: int
Max distance in pixels that is sampled.
Returns: array
Numpy array with all the vertices generated of shape (m,2).