Ellipse#

class gbox.gshape.ellipse.GShape2D#

Bases: GShape, PlotMixin

property equivalent_radius: float#
property centre: Point2D | tuple[float, float]#
property major_axis_angle: float#
property pose: tuple[float, float, float]#

A triplet of (x, y, theta)

property bounding_box: BoundingBox#
union_of_nspheres()#

It returns the union of n-spheres for the current shape.

union_of_circles(*args, **kwargs) CirclesArray#
property volume: float32#
property area: float32#
property perimeter: float32#
translate_and_rotate(dx: float, dy: float, dtheta: float) GShape2D#
class gbox.gshape.ellipse.EllipticalArc(semi_major_length: float | float32, semi_minor_length: float | float32, centre: Tuple[float | float32, float | float32] | Point2D = (0.0, 0.0), major_axis_angle: float | float32 = 0.0, theta_start: float | float32 = 0.0, theta_end: float | float32 = np.float32(6.2831855))#

Bases: object

centre#
semi_major_length#
semi_minor_length#
major_axis_angle#
theta_start#
theta_end#
property area: float32#
perimeter(closure: Literal['open', 'e2e', 'ece'] = 'open') float32#

Computes the perimeter of the elliptical arc.

Parameters:
closurestr

Type of closure for the arc. Options are: - “open”: only the arc length is considered. - “e2e”: the arc length and the chord length between the two endpoints are considered. - “ece”: the arc length and the chord lengths from the endpoints to the centre are considered.

sample_points(num_points: int | None = None, point_density: float | float32 = 10.0) PointArray2D#

Samples points along the elliptical arc.

point_at_angle(theta: float | float32) Point2D#

Returns the point on the ellipse at the given angle.

points_at_parametric_points(theta: ndarray) PointArray2D#
get_bounding_box() BoundingBox#
aspect_ratio#
eccentricity#
class gbox.gshape.ellipse.CircularArc(radius: float | float32, centre: Tuple[float | float32, float | float32] | Point2D = (0.0, 0.0), theta_1: float | float32 = 0.0, theta_2: float | float32 = np.float32(6.2831855))#

Bases: EllipticalArc

semi_major_length#
semi_minor_length#
centre#
major_axis_angle#
theta_start#
theta_end#
aspect_ratio#
eccentricity#
class gbox.gshape.ellipse.Ellipse(semi_major_length: float | float32, semi_minor_length: float | float32, centre: Tuple[float | float32, float | float32] | Point2D = (0.0, 0.0), major_axis_angle: float | float32 = 0.0)#

Bases: GShape2D

arc#
clone()#
translate_and_rotate(dx: float, dy: float, dtheta: float) Ellipse#
property semi_major_length: float32#
property semi_minor_length: float32#
property centre: Point2D#
property major_axis_angle: float32#
property pose: tuple#

A triplet of (x, y, theta)

property aspect_ratio: float32#
property eccentricity: float32#
property bounding_box: BoundingBox#
property area: float32#

Area of the ellipse.

property volume: float32#

Calculates the volume of the ellipse as a cylinder.

property perimeter: float32#

Perimeter of the ellipse.

classmethod from_params(positional_params: dict[str, float], size_params: dict[str, float]) Ellipse#

Construct an Ellipse from parameter dictionaries.

Parameters:
positional_paramsdict
  • ‘xc’: x-coordinate of the centre.

  • ‘yc’: y-coordinate of the centre.

  • ‘major_axis_angle’: Rotation angle in radians.

size_paramsdict
  • ‘semi_major_length’: Half-length of the primary axis.

  • ‘semi_minor_length’: Half-length of the secondary axis.

eval_boundary_points(num_points: int | None = None, point_density: float | float32 = 10.0) None#

Evaluate boundary points of the ellipse.

get_boundary_points(num_points: int = 100, point_density: float | float32 = 10.0) PointArray2D#

Returns the boundary points of the ellipse.

get_bounding_box() BoundingBox#
contains(p: Point2D | Tuple[float | float32, float | float32], atol: float | float32 = 1e-06) Literal[-1, 0, 1]#

Checks if a point is inside, on, or outside the ellipse.

Returns:
-1point is outside the ellipse
0point is on the ellipse
1point is inside the ellipse
r_shortest(xi: float | float32) float32#

Evaluates the shortest distance to the ellipse locus from a point on the major axis located at a distance xi from the centre of the ellipse.

union_of_nspheres(dh: float | float32 = 0.0) CirclesArray#

It returns the union of n-spheres for the current shape.

get_patch(**kwargs) Patch#

Subclasses must implement this method to return the appropriate matplotlib patch. Any kwargs can be used to control styling.

class gbox.gshape.ellipse.Rectangle(semi_major_length: float | float32, semi_minor_length: float | float32, centre: Tuple[float | float32, float | float32] | Point2D = (0.0, 0.0), major_axis_angle: float | float32 = 0.0)#

Bases: GShape2D

copy()#
classmethod from_end_points(point1: Tuple[float | float32, float | float32], point2: Tuple[float | float32, float | float32]) Rectangle#
classmethod from_params()#

Construct a GShape from the given positional and size parameters.

Parameters:
positional_paramsdict[str, float]

A dictionary containing the positional parameters of the shape.

size_paramsdict[str, float]

A dictionary containing the size parameters of the shape.

eval_boundary_points(num_points: int = 100) None#

Evaluate boundary points of the rectangle.

get_boundary_points(num_points: int = 100) PointArray2D#

Returns the boundary points of the rectangle.

get_bounding_box() BoundingBox#
contains(p: Point2D | Tuple[float | float32, float | float32]) Literal[-1, 0, 1]#
union_of_circles()#
get_patch(**kwargs) Patch#

Subclasses must implement this method to return the appropriate matplotlib patch. Any kwargs can be used to control styling.

property semi_major_length: float32#
property semi_minor_length: float32#
property centre: Point2D#
property major_axis_angle: float32#
property aspect_ratio: float32#
property bounds: list[float]#

Returns the bounds of the rectangle as [x_min, y_min, x_max, y_max].

property perimeter: float32#

Perimeter of the rectangle.

property area: float32#

Area of the rectangle.

property volume: float32#

Calculates the volume of the rectangle as a prism

class gbox.gshape.ellipse.Circle(radius: float | float32, centre: Tuple[float | float32, float | float32] | Point2D = (0.0, 0.0))#

Bases: GShape2D

arc: Ellipse#
property radius: float32#
property centre: Point2D#
property major_axis_angle: float32#
property pose: tuple[float, float, float]#

A triplet of (x, y, theta)

property area: float32#
property volume: float32#

Calculates the volume of the circle as a cylinder.

property bounding_box: BoundingBox#
property perimeter: float32#
union_of_nspheres(*args, **kwargs) CirclesArray#

It returns the union of n-spheres for the current shape.

translate_and_rotate(dx: float, dy: float, dtheta: float = None) Circle#
contains(p: Point2D | Tuple[float | float32, float | float32], tol=1e-08) Literal[-1, 0, 1]#
distance_to(c: Circle) float32#
get_patch(**kwargs) Patch#

Subclasses must implement this method to return the appropriate matplotlib patch. Any kwargs can be used to control styling.

classmethod from_params(positional_params: dict[str, float], size_params: dict[str, float]) Circle#

Construct an Ellipse from parameter dictionaries.

Parameters:
positional_paramsdict
  • ‘xc’: x-coordinate of the centre.

  • ‘yc’: y-coordinate of the centre.

size_paramsdict
  • ‘raidus’: radius of the circle.

class gbox.gshape.ellipse.CirclesArray(circles: List[Circle] | ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, initial_capacity: int = 100)#

Bases: object

add_circles(circles: List[Circle] | ndarray[tuple[int, ...], dtype[_ScalarType_co]]) None#

Add circles from either a list of Circle objects or a numpy array

transform(angle: float | float32 = 0.0, dx: float | float32 = 0.0, dy: float | float32 = 0.0, pivot: Point2D | Tuple[float | float32, float | float32] = (0.0, 0.0), scale: float | float32 | ndarray[tuple[int, ...], dtype[_ScalarType_co]] = 1.0) None#

Updates the current circle set by transformation

clip(x_lim: Tuple[float | float32, float | float32] = (-inf, inf), y_lim: Tuple[float | float32, float | float32] = (-inf, inf), r_lim: Tuple[float | float32, float | float32] = (0.0, inf), inplace: bool = True) ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None#

Returns a copy of circles array within the limits

property xc: ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
property yc: ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
property radii: ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
property centres: ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
property data: ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
centres_point_array() PointArray2D#
bounding_box() BoundingBox#
perimeters()#
areas()#
distances_to(p: Point2D | Tuple[float | float32, float | float32]) ndarray[tuple[int, ...], dtype[_ScalarType_co]]#
contains(p: Point2D | Tuple[float | float32, float | float32], rtol: float | float32 = 1e-06) Literal[-1, 0, 1]#
evaluate_boundaries(pointer_per_circle: int = 36, cycle: bool = False)#
plot(axs=None, *, plot_bbox: bool = False, **kwargs) None#