neuron_morphology.transforms.geometry module

Some handy utilities for working with vector geometries

neuron_morphology.transforms.geometry.get_ccw_vertices(vertices: List[Tuple])[source]

Generates counter clockwise vertices from vertices describing a simple polygon

Method: Simplification of the shoelace formula, which calculates area of a simple polygon by integrating the area under each line segment of the polygon. If the total area is positive, the vertices were traversed in clockwise order, and if it is negative, they were traversed in counterclockwise order.

Parameters:
vertices: vertices describing a convex polygon

(vertices[0] = vertices[-1])

Returns:
vertices in counter clockwise order
neuron_morphology.transforms.geometry.get_ccw_vertices_from_two_lines(line1: List[Tuple], line2: List[Tuple])[source]

Convenience method two do both get_vertices_from_two_lines() and get_ccw_vertices()

neuron_morphology.transforms.geometry.get_vertices_from_two_lines(line1: List[Tuple], line2: List[Tuple])[source]

Generates circular vertices from two lines

Parameters:
line1, line2: List of coordinates describing two lines
Returns:
vertices of the simple polygon created from line 1 and 2
(first vertex = last vertex)
1-2-3-4
5-6-7-8 -> [1-2-3-4-8-7-6-5-1]