Point#

class gbox.base.PointND(*coords: float | float32)#

Bases: object

Point class for representing a point in N-dimensional space

coor#
property dim: int#

Returns the dimension of the point

distance_to(q: PointND | Sequence) float32#
in_bounds(lower_bound: PointND | Sequence[float], upper_bound: PointND | Sequence[float]) bool#
reflection(q: PointND, p1: PointND, p2: PointND)#

Reflects the current point about a line connecting p1 and p2

is_close_to(q: PointND | Sequence, rtol: float = 1e-05, atol: float = 1e-08) bool#

Checks if the current point is close to other point ‘p’

Parameters:
q“PointND”

The other point to be compared

rtolfloat

Relative tolerance, defaults to 1e-5

atolfloat

Absolute tolerance, defaults to 1e-8

Returns:
bool

True if the current point is close to other point ‘p’, False otherwise.

Examples

>>> PointND(1.0, 2.0).is_close_to((1.0 + 1e-08, 2.0 + 1e-07))
True
>>> PointND(1.0, 2.0).is_close_to((3.0 + 1e-08, 4.0 + 1e-07))
False
class gbox.base.Point2D(x: float | float32, y: float | float32)#

Bases: PointND

property x: float32#
property y: float32#
slope(q: Point2D | Sequence[float], eps: float = 1e-06) float32#

Returns the slope of the line joining the current point and other point ‘q’.

angle(p2: Point2D | Tuple[float | float32, float | float32], rad=True) float32#

Returns the angle between the current point and other point ‘p2’

Parameters:
p2Union[list[float], “PointND”]

Point or sequence of float_type

radbool

If True, returns angle in radians, otherwise in degrees

Returns:
float_type

Angle

Examples

>>> p = Point.from_([1.0, 2.0])
>>> q = Point.from_([3.0, 4.0])
>>> p.angle(q)
0.7853981633974483
transform(angle: float | float32 = 0.0, dx: float | float32 = 0.0, dy: float | float32 = 0.0, *, order: Literal['RT', 'TR'] = 'RT') Point2D#

Returns a new point transformed by rotation and translation around the origin