LineCarrier
- class LineCarrier(angle: float, distance_from_origin: float, attributes_set: Set[ElementAttributes] | None = None)
A
LineCarrier
represents the equation of a line parameterized by the angle it makes with the x-axis and the distance from the origin to its perpendicular projection on the infinite line.Specifically, this parameterization resembles the polar form
r = d * csc(θ - α)
whered
is the distance from the origin andα
is the angle it makes with the x-axis.- Parameters:
angle – The angle the carrier makes with the x-axis.
distance_from_origin – The distance from the origin to its perpendicular projection on the carrier.
attributes_set – The set of
ElementAttributes
present in elements on this carrier.
Attributes
The angle the carrier makes with the x-axis.
The distance from the origin to its perpendicular projection on the carrier.
Methods
Computes the point on this carrier that is
distance
(signed) away from the origin's perpendicular projection on this carrier.Return
True
ifpoint
is coincident to this carrier.Return
True
if this carrier is equivalent to another.Find all intersection points between this carrier and another.
Computes the
LineCarrier
that passes through two points.Returns the bisector of two line carriers.
Group elements by
ElementAttributes
.Group elements by coequality.
Maximize a group of elements.
Computes the signed distance from
point
's perpendicular projection on this carrier to the origin's.- antiproject(distance: float) ndarray[3]
Computes the point on this carrier that is
distance
(signed) away from the origin’s perpendicular projection on this carrier.This can be used in tandem with
project()
to compute the perpendicular projection of apoint
onto this carrier:projection = carrier.antiproject(carrier.project(point))
.
- contains_point(point: ArrayLike) bool
Return
True
ifpoint
is coincident to this carrier. Fuzzy with tolerance.
- equivalent_to(other: LineCarrier) bool
Return
True
if this carrier is equivalent to another. Fuzzy with tolerance.
- find_intersections(other: Carrier) ndarray
Find all intersection points between this carrier and another. The output should be a numpy array of shape
(n, 3)
where each row is an intersection point. If there are no intersections, returnnp.zeros((0, 3))
.
- classmethod from_points(start: ndarray[3], end: ndarray[3]) LineCarrier
Computes the
LineCarrier
that passes through two points.
- static get_bisector(line1: LineCarrier, line2: LineCarrier) LineCarrier
Returns the bisector of two line carriers.
Specifically, this is the
LineCarrier
that passes through the intersection point ofline1
andline2
, bisecting the angle made at that intersection. If the two lines are parallel, the bisector is simply halfway between the two.Takes the union of both carriers’
ElementAttributes
.
- classmethod group_elements_by_attribute(elements: Iterable[E_co]) Dict[ElementAttributes, List[E_co]]
Group elements by
ElementAttributes
.- Parameters:
elements – Elements to group.
- Returns:
A mapping of
ElementAttributes
to lists ofShapeElement
instances that have the attributes used as the key in the map.
- classmethod group_elements_by_coequality(elements: Iterable[E_co]) List[List[E_co]]
Group elements by coequality. Two
ShapeElement
instances are considered coequal if they have spatially equivalent carriers ( checked withequivalent_to()
withmatch_attributes=False
).- Parameters:
elements – Elements to group.
- Returns:
A list of elements grouped by coequality. Each entry in this list is a list of coequal elements.
- classmethod maximize(elements: Sequence[E_co]) List[E_co]
Maximize a group of elements. Elements are considered maximal if there are no two elements such that
coincident_with()
returnsTrue
.Specifically, if two elements visually appear to be one, replace the two with the one element they appear to be.
Maximization also performs calibration, which involves finding the “average” carrier of each set of coequal elements and projecting the resulting maximal elements onto this average carrier. This helps account for floating point error in the long run.
- project(point: ndarray[3]) float
Computes the signed distance from
point
’s perpendicular projection on this carrier to the origin’s.This can be used in tandem with
antiproject()
to compute the perpendicular projection ofpoint
onto this carrier:projection = carrier.antiproject(carrier.project(point))
.
- angle
The angle the carrier makes with the x-axis.
- distance_from_origin
The distance from the origin to its perpendicular projection on the carrier.