Welcome to ground’s documentation!
Note
If object is not listed in documentation it should be considered as implementation detail that can change and should not be relied upon.
context module
- final class ground.context.Context(*, box_cls: type[~ground.hints.Box[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Box'>, contour_cls: type[~ground.hints.Contour[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Contour'>, coordinate_factory: ~collections.abc.Callable[[int], ~ground._core.hints.ScalarT], empty_cls: type[~ground.hints.Empty[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Empty'>, mix_cls: type[~ground.hints.Mix[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Mix'>, multipoint_cls: type[~ground.hints.Multipoint[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Multipoint'>, multipolygon_cls: type[~ground.hints.Multipolygon[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Multipolygon'>, multisegment_cls: type[~ground.hints.Multisegment[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Multisegment'>, point_cls: type[~ground.hints.Point[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Point'>, polygon_cls: type[~ground.hints.Polygon[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Polygon'>, segment_cls: type[~ground.hints.Segment[~ground._core.hints.ScalarT]] = <class 'ground._core.geometries.Segment'>, sqrt: ~collections.abc.Callable[[~typing.Any], ~ground._core.hints.ScalarT])[source]
Represents common language for computational geometry.
- property coordinate_factory: Callable[[int], ScalarT]
Returns coordinate factory.
- property cross_product: Callable[[Point[ScalarT], Point[ScalarT], Point[ScalarT], Point[ScalarT]], ScalarT]
Returns cross product of the segments.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.cross_product( ... Point(0, 0), Point(0, 1), Point(0, 0), Point(1, 0) ... ) == -1 True >>> context.cross_product( ... Point(0, 0), Point(1, 0), Point(0, 0), Point(1, 0) ... ) == 0 True >>> context.cross_product( ... Point(0, 0), Point(1, 0), Point(0, 0), Point(0, 1) ... ) == 1 True
- property dot_product: Callable[[Point[ScalarT], Point[ScalarT], Point[ScalarT], Point[ScalarT]], ScalarT]
Returns dot product of the segments.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.dot_product( ... Point(0, 0), Point(1, 0), Point(0, 0), Point(-1, 0) ... ) == -1 True >>> context.dot_product( ... Point(0, 0), Point(1, 0), Point(0, 0), Point(0, 1) ... ) == 0 True >>> context.dot_product( ... Point(0, 0), Point(1, 0), Point(0, 0), Point(1, 0) ... ) == 1 True
- property multipoint_cls: type[Multipoint[ScalarT]]
Returns type of multipoints.
- property multipolygon_cls: type[Multipolygon[ScalarT]]
Returns type of multipolygons.
- property multisegment_cls: type[Multisegment[ScalarT]]
Returns type of multisegments.
- property points_squared_distance: Callable[[Point[ScalarT], Point[ScalarT]], ScalarT]
Returns squared Euclidean distance between two points.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.points_squared_distance(Point(0, 0), Point(0, 0)) == 0 True >>> context.points_squared_distance(Point(0, 0), Point(1, 0)) == 1 True >>> context.points_squared_distance(Point(0, 1), Point(1, 0)) == 2 True
- property sqrt: Callable[[Any], ScalarT]
Returns function for computing square root.
- property zero: ScalarT
Returns zero.
- angle_kind(vertex: Point[ScalarT], first_ray_point: Point[ScalarT], second_ray_point: Point[ScalarT], /) Kind[source]
Returns function for computing angle kind.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> from ground.enums import Kind >>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> ( ... context.angle_kind(Point(0, 0), Point(1, 0), Point(-1, 0)) ... is Kind.OBTUSE ... ) True >>> ( ... context.angle_kind(Point(0, 0), Point(1, 0), Point(0, 1)) ... is Kind.RIGHT ... ) True >>> ( ... context.angle_kind(Point(0, 0), Point(1, 0), Point(1, 0)) ... is Kind.ACUTE ... ) True
- angle_orientation(vertex: Point[ScalarT], first_ray_point: Point[ScalarT], second_ray_point: Point[ScalarT], /) Orientation[source]
Returns function for computing angle orientation.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> from ground.enums import Orientation >>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> ( ... context.angle_orientation( ... Point(0, 0), Point(0, 1), Point(1, 0) ... ) ... is Orientation.CLOCKWISE ... ) True >>> ( ... context.angle_orientation( ... Point(0, 0), Point(1, 0), Point(1, 0) ... ) ... is Orientation.COLLINEAR ... ) True >>> ( ... context.angle_orientation( ... Point(0, 0), Point(1, 0), Point(0, 1) ... ) ... is Orientation.COUNTERCLOCKWISE ... ) True
- box_point_squared_distance(box: Box[ScalarT], point: Point[ScalarT], /) ScalarT[source]
Returns squared Euclidean distance between box and a point.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Point = context.box_cls, context.point_cls >>> context.box_point_squared_distance( ... Box(0, 1, 0, 1), Point(1, 1) ... ) == 0 True >>> context.box_point_squared_distance( ... Box(0, 1, 0, 1), Point(2, 1) ... ) == 1 True >>> context.box_point_squared_distance( ... Box(0, 1, 0, 1), Point(2, 2) ... ) == 2 True
- box_segment_squared_distance(box: Box[ScalarT], segment: Segment[ScalarT], /) ScalarT[source]
Returns squared Euclidean distance between box and a segment.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box = context.box_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.box_segment_squared_distance( ... Box(0, 1, 0, 1), Segment(Point(0, 0), Point(1, 1)) ... ) == 0 True >>> context.box_segment_squared_distance( ... Box(0, 1, 0, 1), Segment(Point(2, 0), Point(2, 1)) ... ) == 1 True >>> context.box_segment_squared_distance( ... Box(0, 1, 0, 1), Segment(Point(2, 2), Point(3, 2)) ... ) == 2 True
- contour_box(contour: Contour[ScalarT], /) Box[ScalarT][source]
Constructs box from contour.
- Time complexity:
O(vertices_count)- Memory complexity:
O(1)
where
vertices_count = len(contour.vertices).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Contour, Point = ( ... context.box_cls, ... context.contour_cls, ... context.point_cls, ... ) >>> ( ... context.contour_box( ... Contour( ... [Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)] ... ) ... ) ... == Box(0, 1, 0, 1) ... ) True
- contour_centroid(contour: Contour[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a contour.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour, Point = context.contour_cls, context.point_cls >>> ( ... context.contour_centroid( ... Contour( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... ) ... == Point(1, 1) ... ) True
- contour_length(contour: Contour[ScalarT], /) ScalarT[source]
Returns Euclidean length of a contour.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.contour_length( ... Contour([Point(0, 0), Point(3, 0), Point(0, 4)]) ... ) == 12 True >>> context.contour_length( ... Contour([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)]) ... ) == 4 True
- contour_segments(contour: Contour[ScalarT], /) Sequence[Segment[ScalarT]][source]
Constructs segments of a contour.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.contour_segments( ... Contour( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... ) ... == [ ... Segment(Point(0, 0), Point(2, 0)), ... Segment(Point(2, 0), Point(2, 2)), ... Segment(Point(2, 2), Point(0, 2)), ... Segment(Point(0, 2), Point(0, 0)), ... ] ... ) True
- contours_box(contours: Sequence[Contour[ScalarT]], /) Box[ScalarT][source]
Constructs box from contours.
- Time complexity:
O(vertices_count)- Memory complexity:
O(1)
where
vertices_count = sum(len(contour.vertices) for contour in contours).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box = context.box_cls >>> Contour = context.contour_cls >>> Point = context.point_cls >>> (context.contours_box([Contour([Point(0, 0), Point(1, 0), ... Point(1, 1), Point(0, 1)]), ... Contour([Point(1, 1), Point(2, 1), ... Point(2, 2), Point(1, 2)])]) ... == Box(0, 2, 0, 2)) True
- is_region_convex(contour: Contour[ScalarT], /) bool[source]
Checks if region (given its contour) is convex.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> context.is_region_convex( ... Contour([Point(0, 0), Point(3, 0), Point(1, 1), Point(0, 3)]) ... ) False >>> context.is_region_convex( ... Contour([Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)]) ... ) True
- locate_point_in_point_point_point_circle(point: Point[ScalarT], first: Point[ScalarT], second: Point[ScalarT], third: Point[ScalarT], /) Location[source]
Returns location of point in point-point-point circle.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> from ground.enums import Location >>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> ( ... context.locate_point_in_point_point_point_circle( ... Point(1, 1), Point(0, 0), Point(2, 0), Point(0, 2) ... ) ... is Location.INTERIOR ... ) True >>> ( ... context.locate_point_in_point_point_point_circle( ... Point(2, 2), Point(0, 0), Point(2, 0), Point(0, 2) ... ) ... is Location.BOUNDARY ... ) True >>> ( ... context.locate_point_in_point_point_point_circle( ... Point(3, 3), Point(0, 0), Point(2, 0), Point(0, 2) ... ) ... is Location.EXTERIOR ... ) True
- merged_box(first_box: Box[ScalarT], second_box: Box[ScalarT], /) Box[ScalarT][source]
Merges two boxes.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box = context.box_cls >>> ( ... context.merged_box(Box(0, 1, 0, 1), Box(1, 2, 1, 2)) ... == Box(0, 2, 0, 2) ... ) True
- multipoint_centroid(multipoint: Multipoint[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a multipoint.
- Time complexity:
O(len(multipoint.points))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> context.multipoint_centroid( ... Multipoint( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... ) == Point(1, 1) True
- multipolygon_centroid(multipolygon: Multipolygon[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a multipolygon.
- Time complexity:
O(len(vertices_count))- Memory complexity:
O(1)
where
vertices_count = sum(len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes) for polygon in multipolygon.polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> Multipolygon = context.multipolygon_cls >>> (context.multipolygon_centroid( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(1, 1), Point(0, 1)]), ... []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(2, 2), Point(1, 2)]), ... [])])) ... == Point(1, 1)) True
- multisegment_centroid(multisegment: Multisegment[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a multisegment.
- Time complexity:
O(len(multisegment.segments))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> Multisegment = context.multisegment_cls >>> ( ... context.multisegment_centroid( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(2, 0)), ... Segment(Point(2, 0), Point(2, 2)), ... Segment(Point(0, 2), Point(2, 2)), ... Segment(Point(0, 0), Point(0, 2)), ... ] ... ) ... ) ... == Point(1, 1) ... ) True
- multisegment_length(multisegment: Multisegment[ScalarT], /) ScalarT[source]
Returns Euclidean length of a multisegment.
- Time complexity:
O(len(multisegment.segments))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.multisegment_length( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ) ... ) == 2 True >>> context.multisegment_length( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(3, 4)), ... ] ... ) ... ) == 6 True
- points_convex_hull(points: Sequence[Point[ScalarT]], /) Sequence[Point[ScalarT]][source]
Constructs convex hull of points.
- Time complexity:
O(points_count * log(points_count))- Memory complexity:
O(points_count)
where
points_count = len(points).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> ( ... context.points_convex_hull( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... == [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) True
- points_box(points: Sequence[Point[ScalarT]], /) Box[ScalarT][source]
Constructs box from points.
- Time complexity:
O(len(points))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Point = context.box_cls, context.point_cls >>> ( ... context.points_box( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... == Box(0, 2, 0, 2) ... ) True
- polygon_box(polygon: Polygon[ScalarT], /) Box[ScalarT][source]
Constructs box from polygon.
- Time complexity:
O(vertices_count)- Memory complexity:
O(1)
where
vertices_count = len(polygon.border.vertices).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Contour, Point, Polygon = ( ... context.box_cls, ... context.contour_cls, ... context.point_cls, ... context.polygon_cls, ... ) >>> context.polygon_box( ... Polygon( ... Contour( ... [Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)] ... ), ... [], ... ) ... ) == Box(0, 1, 0, 1) True
- polygon_centroid(polygon: Polygon[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a polygon.
- Time complexity:
O(vertices_count)- Memory complexity:
O(1)
where
vertices_count = len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> context.polygon_centroid( ... Polygon(Contour([Point(0, 0), Point(4, 0), Point(4, 4), ... Point(0, 4)]), ... [Contour([Point(1, 1), Point(1, 3), Point(3, 3), ... Point(3, 1)])])) == Point(2, 2) True
- polygons_box(polygons: Sequence[Polygon[ScalarT]], /) Box[ScalarT][source]
Constructs box from polygons.
- Time complexity:
O(vertices_count)- Memory complexity:
O(1)
where
vertices_count = sum(len(polygon.border.vertices) for polygon in polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Contour, Point, Polygon = (context.box_cls, ... context.contour_cls, ... context.point_cls, ... context.polygon_cls) >>> context.polygons_box( ... [Polygon(Contour([Point(0, 0), Point(1, 0), Point(1, 1), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), Point(2, 2), ... Point(1, 2)]), [])]) == Box(0, 2, 0, 2) True
- region_centroid(contour: Contour[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a region given its contour.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> ( ... context.region_centroid( ... Contour( ... [Point(0, 0), Point(2, 0), Point(2, 2), Point(0, 2)] ... ) ... ) ... == Point(1, 1) ... ) True
- region_signed_area(contour: Contour[ScalarT], /) ScalarT[source]
Returns signed area of the region given its contour.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> ( ... context.region_signed_area( ... Contour( ... [Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)] ... ) ... ) ... == 1 ... ) True >>> ( ... context.region_signed_area( ... Contour( ... [Point(0, 0), Point(0, 1), Point(1, 1), Point(1, 0)] ... ) ... ) ... == -1 ... ) True
- replace(*, box_cls: type[Box[ScalarT]] | None = None, contour_cls: type[Contour[ScalarT]] | None = None, coordinate_factory: Callable[[int], ScalarT] | None = None, empty_cls: type[Empty[ScalarT]] | None = None, mix_cls: type[Mix[ScalarT]] | None = None, multipoint_cls: type[Multipoint[ScalarT]] | None = None, multipolygon_cls: type[Multipolygon[ScalarT]] | None = None, multisegment_cls: type[Multisegment[ScalarT]] | None = None, point_cls: type[Point[ScalarT]] | None = None, polygon_cls: type[Polygon[ScalarT]] | None = None, segment_cls: type[Segment[ScalarT]] | None = None, sqrt: Callable[[Any], ScalarT] | None = None) Context[ScalarT][source]
Constructs context from the original one replacing given parameters.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> from fractions import Fraction >>> from ground.context import Context >>> fraction_context = context.replace(coordinate_factory=Fraction) >>> isinstance(fraction_context, Context) True >>> fraction_context.coordinate_factory is Fraction True
- rotate_contour(contour: Contour[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Contour[ScalarT][source]
Returns contour rotated by given angle around given center.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(len(contour.vertices))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> ( ... context.rotate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), ... 1, ... 0, ... Point(0, 1), ... ) ... == Contour([Point(0, 0), Point(1, 0), Point(0, 1)]) ... ) True >>> ( ... context.rotate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), ... 0, ... 1, ... Point(0, 1), ... ) ... == Contour([Point(1, 1), Point(1, 2), Point(0, 1)]) ... ) True
- rotate_contour_around_origin(contour: Contour[ScalarT], cosine: ScalarT, sine: ScalarT, /) Contour[ScalarT][source]
Returns contour rotated by given angle around origin.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(len(contour.vertices))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> ( ... context.rotate_contour_around_origin( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 1, 0 ... ) ... == Contour([Point(0, 0), Point(1, 0), Point(0, 1)]) ... ) True >>> ( ... context.rotate_contour_around_origin( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 0, 1 ... ) ... == Contour([Point(0, 0), Point(0, 1), Point(-1, 0)]) ... ) True
- rotate_multipoint(multipoint: Multipoint[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Multipoint[ScalarT][source]
Returns multipoint rotated by given angle around given center.
- Time complexity:
O(len(multipoint.points))- Memory complexity:
O(len(multipoint.points))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> ( ... context.rotate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 1, 0, Point(0, 1) ... ) ... == Multipoint([Point(0, 0), Point(1, 0)]) ... ) True >>> ( ... context.rotate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 0, 1, Point(0, 1) ... ) ... == Multipoint([Point(1, 1), Point(1, 2)]) ... ) True
- rotate_multipoint_around_origin(multipoint: Multipoint[ScalarT], cosine: ScalarT, sine: ScalarT, /) Multipoint[ScalarT][source]
Returns multipoint rotated by given angle around origin.
- Time complexity:
O(len(multipoint.points))- Memory complexity:
O(len(multipoint.points))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> ( ... context.rotate_multipoint_around_origin( ... Multipoint([Point(0, 0), Point(1, 0)]), 1, 0 ... ) ... == Multipoint([Point(0, 0), Point(1, 0)]) ... ) True >>> ( ... context.rotate_multipoint_around_origin( ... Multipoint([Point(0, 0), Point(1, 0)]), 0, 1 ... ) ... == Multipoint([Point(0, 0), Point(0, 1)]) ... ) True
- rotate_multipolygon(multipolygon: Multipolygon[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Multipolygon[ScalarT][source]
Returns multipolygon rotated by given angle around given center.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = sum(len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes) for polygon in multipolygon.polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipolygon = context.multipolygon_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.rotate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])]), ... 1, 0, Point(0, 1)) ... == Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])])) True >>> (context.rotate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])]), ... 0, 1, Point(0, 1)) ... == Multipolygon([Polygon(Contour([Point(1, 1), Point(1, 2), ... Point(0, 1)]), [])])) True
- rotate_multipolygon_around_origin(multipolygon: Multipolygon[ScalarT], cosine: ScalarT, sine: ScalarT, /) Multipolygon[ScalarT][source]
Returns multipolygon rotated by given angle around origin.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = sum(len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes) for polygon in multipolygon.polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipolygon = context.multipolygon_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.rotate_multipolygon_around_origin( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])]), ... 1, 0) ... == Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])])) True >>> (context.rotate_multipolygon_around_origin( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), [])]), ... 0, 1) ... == Multipolygon([Polygon(Contour([Point(0, 0), Point(0, 1), ... Point(-1, 0)]), [])])) True
- rotate_multisegment(multisegment: Multisegment[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Multisegment[ScalarT][source]
Returns multisegment rotated by given angle around given center.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.rotate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 0, ... Point(0, 1), ... ) ... == Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ) ... ) True >>> ( ... context.rotate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 1, ... Point(0, 1), ... ) ... == Multisegment( ... [ ... Segment(Point(1, 1), Point(1, 2)), ... Segment(Point(1, 1), Point(0, 1)), ... ] ... ) ... ) True
- rotate_multisegment_around_origin(multisegment: Multisegment[ScalarT], cosine: ScalarT, sine: ScalarT, /) Multisegment[ScalarT][source]
Returns multisegment rotated by given angle around origin.
- Time complexity:
O(len(multisegment.segments))- Memory complexity:
O(len(multisegment.segments))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.rotate_multisegment_around_origin( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 0, ... ) ... == Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ) ... ) True >>> ( ... context.rotate_multisegment_around_origin( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 1, ... ) ... == Multisegment( ... [ ... Segment(Point(0, 0), Point(0, 1)), ... Segment(Point(0, 0), Point(-1, 0)), ... ] ... ) ... ) True
- rotate_point(point: Point[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Point[ScalarT][source]
Returns point rotated by given angle around given center.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.rotate_point(Point(1, 0), 1, 0, Point(0, 1)) == Point(1, 0) True >>> context.rotate_point(Point(1, 0), 0, 1, Point(0, 1)) == Point(1, 2) True
- rotate_point_around_origin(point: Point[ScalarT], cosine: ScalarT, sine: ScalarT, /) Point[ScalarT][source]
Returns point rotated by given angle around origin.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> ( ... context.rotate_point_around_origin(Point(1, 0), 1, 0) ... == Point(1, 0) ... ) True >>> ( ... context.rotate_point_around_origin(Point(1, 0), 0, 1) ... == Point(0, 1) ... ) True
- rotate_polygon(polygon: Polygon[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Polygon[ScalarT][source]
Returns polygon rotated by given angle around given center.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.rotate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 0, Point(0, 1)) ... == Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), [])) True >>> (context.rotate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 1, Point(0, 1)) ... == Polygon(Contour([Point(1, 1), Point(1, 2), Point(0, 1)]), [])) True
- rotate_polygon_around_origin(polygon: Polygon[ScalarT], cosine: ScalarT, sine: ScalarT, /) Polygon[ScalarT][source]
Returns polygon rotated by given angle around origin.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.rotate_polygon_around_origin( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 0) ... == Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), [])) True >>> (context.rotate_polygon_around_origin( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 1) ... == Polygon(Contour([Point(0, 0), Point(0, 1), Point(-1, 0)]), [])) True
- rotate_segment(segment: Segment[ScalarT], cosine: ScalarT, sine: ScalarT, center: Point[ScalarT], /) Segment[ScalarT][source]
Returns segment rotated by given angle around given center.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.rotate_segment( ... Segment(Point(0, 0), Point(1, 0)), 1, 0, Point(0, 1) ... ) ... == Segment(Point(0, 0), Point(1, 0)) ... ) True >>> ( ... context.rotate_segment( ... Segment(Point(0, 0), Point(1, 0)), 0, 1, Point(0, 1) ... ) ... == Segment(Point(1, 1), Point(1, 2)) ... ) True
- rotate_segment_around_origin(segment: Segment[ScalarT], cosine: ScalarT, sine: ScalarT, /) Segment[ScalarT][source]
Returns segment rotated by given angle around origin.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.rotate_segment_around_origin( ... Segment(Point(0, 0), Point(1, 0)), 1, 0 ... ) ... == Segment(Point(0, 0), Point(1, 0)) ... ) True >>> ( ... context.rotate_segment_around_origin( ... Segment(Point(0, 0), Point(1, 0)), 0, 1 ... ) ... == Segment(Point(0, 0), Point(0, 1)) ... ) True
- scale_contour(contour: Contour[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Contour[ScalarT] | Multipoint[ScalarT] | Segment[ScalarT][source]
Returns contour scaled by given factor.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(len(contour.vertices))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.scale_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 0, 0 ... ) ... == Multipoint([Point(0, 0)]) ... ) True >>> ( ... context.scale_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 1, 0 ... ) ... == Segment(Point(0, 0), Point(1, 0)) ... ) True >>> ( ... context.scale_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 0, 1 ... ) ... == Segment(Point(0, 0), Point(0, 1)) ... ) True >>> ( ... context.scale_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 1, 1 ... ) ... == Contour([Point(0, 0), Point(1, 0), Point(0, 1)]) ... ) True
- scale_multipoint(multipoint: Multipoint[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Multipoint[ScalarT][source]
Returns multipoint scaled by given factor.
- Time complexity:
O(len(multipoint.points))- Memory complexity:
O(len(multipoint.points))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> ( ... context.scale_multipoint( ... Multipoint([Point(0, 0), Point(1, 1)]), 0, 0 ... ) ... == Multipoint([Point(0, 0)]) ... ) True >>> ( ... context.scale_multipoint( ... Multipoint([Point(0, 0), Point(1, 1)]), 1, 0 ... ) ... == Multipoint([Point(0, 0), Point(1, 0)]) ... ) True >>> ( ... context.scale_multipoint( ... Multipoint([Point(0, 0), Point(1, 1)]), 0, 1 ... ) ... == Multipoint([Point(0, 0), Point(0, 1)]) ... ) True >>> ( ... context.scale_multipoint( ... Multipoint([Point(0, 0), Point(1, 1)]), 1, 1 ... ) ... == Multipoint([Point(0, 0), Point(1, 1)]) ... ) True
- scale_multipolygon(multipolygon: Multipolygon[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Multipoint[ScalarT] | Multipolygon[ScalarT] | Multisegment[ScalarT][source]
Returns multipolygon scaled by given factor.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = sum(len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes) for polygon in multipolygon.polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipoint = context.multipoint_cls >>> Multipolygon = context.multipolygon_cls >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> Segment = context.segment_cls >>> (context.scale_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 0, 0) ... == Multipoint([Point(0, 0)])) True >>> (context.scale_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 1, 0) ... == Multisegment([Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(1, 0), Point(2, 0))])) True >>> (context.scale_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 0, 1) ... == Multisegment([Segment(Point(0, 0), Point(0, 1)), ... Segment(Point(0, 1), Point(0, 2))])) True >>> (context.scale_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 1, 1) ... == Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])])) True
- scale_multisegment(multisegment: Multisegment[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Empty[ScalarT] | Segment[ScalarT] | Multisegment[ScalarT] | Contour[ScalarT] | Mix[ScalarT] | Multipoint[ScalarT] | Polygon[ScalarT] | Multipolygon[ScalarT][source]
Returns multisegment scaled by given factor.
- Time complexity:
O(len(multisegment.segments))- Memory complexity:
O(len(multisegment.segments))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> EMPTY = context.empty >>> Mix = context.mix_cls >>> Multipoint = context.multipoint_cls >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.scale_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 0, ... ) ... == Multipoint([Point(0, 0)]) ... ) True >>> ( ... context.scale_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 0, ... ) ... == Mix( ... Multipoint([Point(0, 0)]), ... Segment(Point(0, 0), Point(1, 0)), ... EMPTY, ... ) ... ) True >>> ( ... context.scale_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 1, ... ) ... == Mix( ... Multipoint([Point(0, 0)]), ... Segment(Point(0, 0), Point(0, 1)), ... EMPTY, ... ) ... ) True >>> ( ... context.scale_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 1, ... ) ... == Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ) ... ) True
- scale_point(point: Point[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Point[ScalarT][source]
Returns point scaled by given factor.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.scale_point(Point(1, 1), 0, 0) == Point(0, 0) True >>> context.scale_point(Point(1, 1), 1, 0) == Point(1, 0) True >>> context.scale_point(Point(1, 1), 0, 1) == Point(0, 1) True >>> context.scale_point(Point(1, 1), 1, 1) == Point(1, 1) True
- scale_polygon(polygon: Polygon[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Multipoint[ScalarT] | Polygon[ScalarT] | Segment[ScalarT][source]
Returns polygon scaled by given factor.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> Segment = context.segment_cls >>> (context.scale_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 0) ... == Multipoint([Point(0, 0)])) True >>> (context.scale_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 0) ... == Segment(Point(0, 0), Point(1, 0))) True >>> (context.scale_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 1) ... == Segment(Point(0, 0), Point(0, 1))) True >>> (context.scale_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 1) ... == Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), [])) True
- scale_segment(segment: Segment[ScalarT], factor_x: ScalarT, factor_y: ScalarT, /) Multipoint[ScalarT] | Segment[ScalarT][source]
Returns segment scaled by given factor.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.scale_segment(Segment(Point(0, 0), Point(1, 1)), 0, 0) ... == Multipoint([Point(0, 0)]) ... ) True >>> ( ... context.scale_segment(Segment(Point(0, 0), Point(1, 1)), 1, 0) ... == Segment(Point(0, 0), Point(1, 0)) ... ) True >>> ( ... context.scale_segment(Segment(Point(0, 0), Point(1, 1)), 0, 1) ... == Segment(Point(0, 0), Point(0, 1)) ... ) True >>> ( ... context.scale_segment(Segment(Point(0, 0), Point(1, 1)), 1, 1) ... == Segment(Point(0, 0), Point(1, 1)) ... ) True
- segment_box(segment: Segment[ScalarT], /) Box[ScalarT][source]
Constructs box from segment.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Point, Segment = ( ... context.box_cls, ... context.point_cls, ... context.segment_cls, ... ) >>> ( ... context.segment_box(Segment(Point(0, 1), Point(2, 3))) ... == Box(0, 2, 1, 3) ... ) True
- segment_centroid(segment: Segment[ScalarT], /) Point[ScalarT][source]
Constructs centroid of a segment.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point, Segment = context.point_cls, context.segment_cls >>> ( ... context.segment_centroid(Segment(Point(0, 1), Point(2, 3))) ... == Point(1, 2) ... ) True
- segment_contains_point(segment: Segment[ScalarT], point: Point[ScalarT], /) bool[source]
Checks if a segment contains given point.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(0, 0) ... ) True >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(0, 2) ... ) False >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(1, 0) ... ) True >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(1, 1) ... ) False >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(2, 0) ... ) True >>> context.segment_contains_point( ... Segment(Point(0, 0), Point(2, 0)), Point(3, 0) ... ) False
- segment_length(segment: Segment[ScalarT], /) ScalarT[source]
Returns Euclidean length of a segment.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.segment_length(Segment(Point(0, 0), Point(1, 0))) == 1 True >>> context.segment_length(Segment(Point(0, 0), Point(0, 1))) == 1 True >>> context.segment_length(Segment(Point(0, 0), Point(3, 4))) == 5 True
- segment_point_squared_distance(segment: Segment[ScalarT], point: Point[ScalarT], /) ScalarT[source]
Returns squared Euclidean distance between segment and a point.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.segment_point_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), Point(0, 0) ... ) == 0 True >>> context.segment_point_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), Point(0, 1) ... ) == 1 True >>> context.segment_point_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), Point(2, 1) ... ) == 2 True
- segments_box(segments: Sequence[Segment[ScalarT]], /) Box[ScalarT][source]
Constructs box from segments.
- Time complexity:
O(len(segments))- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Box, Point, Segment = ( ... context.box_cls, ... context.point_cls, ... context.segment_cls, ... ) >>> ( ... context.segments_box( ... [ ... Segment(Point(0, 0), Point(1, 1)), ... Segment(Point(1, 1), Point(2, 2)), ... ] ... ) ... == Box(0, 2, 0, 2) ... ) True
- segments_intersection(first: Segment[ScalarT], second: Segment[ScalarT], /) Point[ScalarT][source]
Returns intersection point of two segments.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.segments_intersection( ... Segment(Point(0, 0), Point(2, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ) ... == Point(0, 0) ... ) True >>> ( ... context.segments_intersection( ... Segment(Point(0, 0), Point(2, 0)), ... Segment(Point(1, 0), Point(1, 1)), ... ) ... == Point(1, 0) ... ) True >>> ( ... context.segments_intersection( ... Segment(Point(0, 0), Point(2, 0)), ... Segment(Point(2, 0), Point(3, 0)), ... ) ... == Point(2, 0) ... ) True
- segments_relation(test: Segment[ScalarT], goal: Segment[ScalarT], /) Relation[source]
Returns relation between two segments.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> from ground.enums import Relation >>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(1, 0), Point(2, 0)), ... ) ... is Relation.DISJOINT ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(0, 0), Point(2, 0)), ... ) ... is Relation.TOUCH ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(2, 0), Point(0, 2)), ... ) ... is Relation.CROSS ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(0, 0), Point(1, 1)), ... ) ... is Relation.COMPOSITE ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(0, 0), Point(2, 2)), ... ) ... is Relation.EQUAL ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(0, 0), Point(3, 3)), ... ) ... is Relation.COMPONENT ... ) True >>> ( ... context.segments_relation( ... Segment(Point(0, 0), Point(2, 2)), ... Segment(Point(1, 1), Point(3, 3)), ... ) ... is Relation.OVERLAP ... ) True
- segments_squared_distance(first: Segment[ScalarT], second: Segment[ScalarT], /) ScalarT[source]
Returns squared Euclidean distance between two segments.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> context.segments_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ) == 0 True >>> context.segments_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 1), Point(1, 1)), ... ) == 1 True >>> context.segments_squared_distance( ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(2, 1), Point(2, 2)), ... ) == 2 True
- translate_contour(contour: Contour[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Contour[ScalarT][source]
Returns contour translated by given step.
- Time complexity:
O(len(contour.vertices))- Memory complexity:
O(len(contour.vertices))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.translate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 0, 0 ... ) ... == Contour([Point(0, 0), Point(1, 0), Point(0, 1)]) ... ) True >>> ( ... context.translate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 1, 0 ... ) ... == Contour([Point(1, 0), Point(2, 0), Point(1, 1)]) ... ) True >>> ( ... context.translate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 0, 1 ... ) ... == Contour([Point(0, 1), Point(1, 1), Point(0, 2)]) ... ) True >>> ( ... context.translate_contour( ... Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), 1, 1 ... ) ... == Contour([Point(1, 1), Point(2, 1), Point(1, 2)]) ... ) True
- translate_multipoint(multipoint: Multipoint[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Multipoint[ScalarT][source]
Returns multipoint translated by given step.
- Time complexity:
O(len(multipoint.points))- Memory complexity:
O(len(multipoint.points))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multipoint = context.multipoint_cls >>> Point = context.point_cls >>> ( ... context.translate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 0, 0 ... ) ... == Multipoint([Point(0, 0), Point(1, 0)]) ... ) True >>> ( ... context.translate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 1, 0 ... ) ... == Multipoint([Point(1, 0), Point(2, 0)]) ... ) True >>> ( ... context.translate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 0, 1 ... ) ... == Multipoint([Point(0, 1), Point(1, 1)]) ... ) True >>> ( ... context.translate_multipoint( ... Multipoint([Point(0, 0), Point(1, 0)]), 1, 1 ... ) ... == Multipoint([Point(1, 1), Point(2, 1)]) ... ) True
- translate_multipolygon(multipolygon: Multipolygon[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Multipolygon[ScalarT][source]
Returns multipolygon translated by given step.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = sum(len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes) for polygon in multipolygon.polygons).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Multipolygon = context.multipolygon_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.translate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 0, 0) ... == Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])])) True >>> (context.translate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 1, 0) ... == Multipolygon([Polygon(Contour([Point(1, 0), Point(2, 0), ... Point(1, 1)]), []), ... Polygon(Contour([Point(2, 1), Point(3, 1), ... Point(2, 2)]), [])])) True >>> (context.translate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 0, 1) ... == Multipolygon([Polygon(Contour([Point(0, 1), Point(1, 1), ... Point(0, 2)]), []), ... Polygon(Contour([Point(1, 2), Point(2, 2), ... Point(1, 3)]), [])])) True >>> (context.translate_multipolygon( ... Multipolygon([Polygon(Contour([Point(0, 0), Point(1, 0), ... Point(0, 1)]), []), ... Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), [])]), 1, 1) ... == Multipolygon([Polygon(Contour([Point(1, 1), Point(2, 1), ... Point(1, 2)]), []), ... Polygon(Contour([Point(2, 2), Point(3, 2), ... Point(2, 3)]), [])])) True
- translate_multisegment(multisegment: Multisegment[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Multisegment[ScalarT][source]
Returns multisegment translated by given step.
- Time complexity:
O(len(multisegment.segments))- Memory complexity:
O(len(multisegment.segments))
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Multisegment = context.multisegment_cls >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.translate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 0, ... ) ... == Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ) ... ) True >>> ( ... context.translate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 0, ... ) ... == Multisegment( ... [ ... Segment(Point(1, 0), Point(2, 0)), ... Segment(Point(1, 0), Point(1, 1)), ... ] ... ) ... ) True >>> ( ... context.translate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 0, ... 1, ... ) ... == Multisegment( ... [ ... Segment(Point(0, 1), Point(1, 1)), ... Segment(Point(0, 1), Point(0, 2)), ... ] ... ) ... ) True >>> ( ... context.translate_multisegment( ... Multisegment( ... [ ... Segment(Point(0, 0), Point(1, 0)), ... Segment(Point(0, 0), Point(0, 1)), ... ] ... ), ... 1, ... 1, ... ) ... == Multisegment( ... [ ... Segment(Point(1, 1), Point(2, 1)), ... Segment(Point(1, 1), Point(1, 2)), ... ] ... ) ... ) True
- translate_point(point: Point[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Point[ScalarT][source]
Returns point translated by given step.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> context.translate_point(Point(0, 0), 0, 0) == Point(0, 0) True >>> context.translate_point(Point(0, 0), 1, 0) == Point(1, 0) True >>> context.translate_point(Point(0, 0), 0, 1) == Point(0, 1) True >>> context.translate_point(Point(0, 0), 1, 1) == Point(1, 1) True
- translate_polygon(polygon: Polygon[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Polygon[ScalarT][source]
Returns polygon translated by given step.
- Time complexity:
O(vertices_count)- Memory complexity:
O(vertices_count)
where
vertices_count = len(polygon.border.vertices) + sum(len(hole.vertices) for hole in polygon.holes).>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Contour = context.contour_cls >>> Point = context.point_cls >>> Polygon = context.polygon_cls >>> (context.translate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 0) ... == Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), [])) True >>> (context.translate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 0) ... == Polygon(Contour([Point(1, 0), Point(2, 0), Point(1, 1)]), [])) True >>> (context.translate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 0, 1) ... == Polygon(Contour([Point(0, 1), Point(1, 1), Point(0, 2)]), [])) True >>> (context.translate_polygon( ... Polygon(Contour([Point(0, 0), Point(1, 0), Point(0, 1)]), []), ... 1, 1) ... == Polygon(Contour([Point(1, 1), Point(2, 1), Point(1, 2)]), [])) True
- translate_segment(segment: Segment[ScalarT], step_x: ScalarT, step_y: ScalarT, /) Segment[ScalarT][source]
Returns segment translated by given step.
- Time complexity:
O(1)- Memory complexity:
O(1)
>>> import math >>> from fractions import Fraction >>> from ground.context import Context >>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt) >>> Point = context.point_cls >>> Segment = context.segment_cls >>> ( ... context.translate_segment( ... Segment(Point(0, 0), Point(1, 0)), 0, 0 ... ) ... == Segment(Point(0, 0), Point(1, 0)) ... ) True >>> ( ... context.translate_segment( ... Segment(Point(0, 0), Point(1, 0)), 1, 0 ... ) ... == Segment(Point(1, 0), Point(2, 0)) ... ) True >>> ( ... context.translate_segment( ... Segment(Point(0, 0), Point(1, 0)), 0, 1 ... ) ... == Segment(Point(0, 1), Point(1, 1)) ... ) True >>> ( ... context.translate_segment( ... Segment(Point(0, 0), Point(1, 0)), 1, 1 ... ) ... == Segment(Point(1, 1), Point(2, 1)) ... ) True
enums module
- class ground.enums.Kind(value)[source]
Represents kinds of angles based on their degrees value in range
[0, 180].- OBTUSE = -1
(90, 180]degrees
- RIGHT = 0
90degrees
- ACUTE = 1
[0, 90)degrees
- class ground.enums.Location(value)[source]
Represents kinds of locations in which point can be relative to geometry.
- EXTERIOR = 0
point lies in the exterior of the geometry
- BOUNDARY = 1
point lies on the boundary of the geometry
- INTERIOR = 2
point lies in the interior of the geometry
- class ground.enums.Orientation(value)[source]
Represents kinds of angle orientations.
- CLOCKWISE = -1
in the same direction as a clock’s hands
- COLLINEAR = 0
to the top and then to the bottom or vice versa
- COUNTERCLOCKWISE = 1
opposite to clockwise
- class ground.enums.Relation(value)[source]
Represents kinds of relations in which geometries can be. Order of members assumes that conditions for previous ones do not hold.
- DISJOINT = 0
intersection is empty
- TOUCH = 1
intersection is a strict subset of each of the geometries, has dimension less than at least of one of the geometries and if we traverse boundary of each of the geometries in any direction then boundary of the other geometry won’t be on one of sides at each point of boundaries intersection
- CROSS = 2
intersection is a strict subset of each of the geometries, has dimension less than at least of one of the geometries and if we traverse boundary of each of the geometries in any direction then boundary of the other geometry will be on both sides at some point of boundaries intersection
- OVERLAP = 3
intersection is a strict subset of each of the geometries and has the same dimension as geometries
- COVER = 4
interior of the geometry is a superset of the other
- ENCLOSES = 5
boundary of the geometry contains at least one boundary point of the other, but not all, interior of the geometry contains other points of the other
- COMPOSITE = 6
geometry is a strict superset of the other and interior/boundary of the geometry is a superset of interior/boundary of the other
- EQUAL = 7
geometries are equal
- COMPONENT = 8
geometry is a strict subset of the other and interior/boundary of the geometry is a subset of interior/boundary of the other
- ENCLOSED = 9
at least one boundary point of the geometry lies on the boundary of the other, but not all, other points of the geometry lie in the interior of the other
- WITHIN = 10
geometry is a subset of the interior of the other
hints module
- class ground.hints.Box(min_x: ScalarT_co, max_x: ScalarT_co, min_y: ScalarT_co, max_y: ScalarT_co, /)
Box is a limited closed region defined by axis-aligned rectangular contour.
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, min_x: ScalarT_co, max_x: ScalarT_co, min_y: ScalarT_co, max_y: ScalarT_co, /) Self[source]
Constructs box given its coordinates limits.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- abstract property max_x: ScalarT_co
Maximum
x-coordinate of the box.
- abstract property max_y: ScalarT_co
Maximum
y-coordinate of the box.
- abstract property min_x: ScalarT_co
Minimum
x-coordinate of the box.
- abstract property min_y: ScalarT_co
Minimum
y-coordinate of the box.
- class ground.hints.Contour(vertices: Sequence[Point[ScalarT_co]], /)
Contour is a linear geometry that represents closed simple polyline defined by a sequence of points (called contour’s vertices).
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, vertices: Sequence[Point[ScalarT_co]], /) Self[source]
Constructs contour given its vertices.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Empty
Represents an empty set of points.
- __init__(*args, **kwargs)
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Mix(discrete: Empty[ScalarT_co] | Multipoint[ScalarT_co], linear: Empty[ScalarT_co] | Segment[ScalarT_co] | Multisegment[ScalarT_co] | Contour[ScalarT_co], shaped: Empty[ScalarT_co] | Polygon[ScalarT_co] | Multipolygon[ScalarT_co], /)
Mix is a set of two or more non-empty geometries with different dimensions.
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, discrete: Empty[ScalarT_co] | Multipoint[ScalarT_co], linear: Empty[ScalarT_co] | Segment[ScalarT_co] | Multisegment[ScalarT_co] | Contour[ScalarT_co], shaped: Empty[ScalarT_co] | Polygon[ScalarT_co] | Multipolygon[ScalarT_co], /) Self[source]
Constructs mix given its components.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- abstract property discrete: Empty[ScalarT_co] | Multipoint[ScalarT_co]
Discrete component of the mix.
- abstract property linear: Empty[ScalarT_co] | Segment[ScalarT_co] | Multisegment[ScalarT_co] | Contour[ScalarT_co]
Linear component of the mix.
- abstract property shaped: Empty[ScalarT_co] | Polygon[ScalarT_co] | Multipolygon[ScalarT_co]
Shaped component of the mix.
- class ground.hints.Multipoint(points: Sequence[Point[ScalarT_co]], /)
Multipoint is a discrete geometry that represents non-empty set of unique points.
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, points: Sequence[Point[ScalarT_co]], /) Self[source]
Constructs multipoint given its points.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Multipolygon(polygons: Sequence[Polygon[ScalarT_co]], /)
Multipolygon is a shaped geometry that represents set of two or more non-overlapping polygons intersecting only in discrete set of points.
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, polygons: Sequence[Polygon[ScalarT_co]], /) Self[source]
Constructs multipolygon given its polygons.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Multisegment(segments: Sequence[Segment[ScalarT_co]], /)
Multisegment is a linear geometry that represents set of two or more non-crossing and non-overlapping segments.
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, segments: Sequence[Segment[ScalarT_co]], /) Self[source]
Constructs multisegment given its segments.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Point(x: ScalarT_co, y: ScalarT_co, /)
Point is a minimal element of the plane defined by pair of real numbers (called point’s coordinates).
Points considered to be sorted lexicographically, with abscissas being compared first.
- abstractmethod __ge__(other: Self, /) bool[source]
Checks if the point is greater than or equal to the other.
- __init__(*args, **kwargs)
- abstractmethod __le__(other: Self, /) bool[source]
Checks if the point is less than or equal to the other.
- abstractmethod static __new__(cls, x: ScalarT_co, y: ScalarT_co, /) Self[source]
Constructs point given its coordinates.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- abstract property x: ScalarT_co
Abscissa of the point.
- abstract property y: ScalarT_co
Ordinate of the point.
- class ground.hints.Polygon(border: Contour[ScalarT_co], holes: Sequence[Contour[ScalarT_co]], /)
Polygon is a shaped geometry that represents limited closed region defined by the pair of outer contour (called polygon’s border) and possibly empty sequence of inner contours (called polygon’s holes).
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, border: Contour[ScalarT_co], holes: Sequence[Contour[ScalarT_co]], /) Self[source]
Constructs polygon given its border and holes.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Scalar(*args, **kwargs)
-
- __init__(*args, **kwargs)
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class ground.hints.Segment(start: Point[ScalarT_co], end: Point[ScalarT_co], /)
Segment (or line segment) is a linear geometry that represents a limited continuous part of the line containing more than one point defined by a pair of unequal points (called segment’s endpoints).
- __init__(*args, **kwargs)
- abstractmethod static __new__(cls, start: Point[ScalarT_co], end: Point[ScalarT_co], /) Self[source]
Constructs segment given its endpoints.
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).