Geometries

LENGTH_UNIT = 1.0

Base unit for lengths. Here to avoid numerical precision issues if dealing with too little numbers.

class JGEXPoint(**data)

Bases: BaseModel

Numerical point.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

x: float
y: float
angle()
Return type:

float

close_enough(point)
Return type:

bool

distance(p)
Return type:

float

distance2(p)
Return type:

float

rot90()
Return type:

JGEXPoint

rotatea(ang)
Return type:

JGEXPoint

rotate(sinb, cosb)
Return type:

JGEXPoint

flip()
Return type:

JGEXPoint

perpendicular_line(line)
Return type:

JGEXLine

foot(line)
Return type:

JGEXPoint

parallel_line(line)
Return type:

JGEXLine

dot(other)
Return type:

float

classmethod deduplicate(points)
Return type:

list[JGEXPoint]

intersect(obj)
Return type:

list[JGEXPoint]

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class JGEXGeometry

Bases: ABC

abstractmethod sample_within(points, *, trials=5, rng)
Return type:

JGEXPoint

class JGEXLine(p1=None, p2=None, coefficients=None)

Bases: JGEXGeometry

Numerical line.

parallel_line(p)
Return type:

JGEXLine

perpendicular_line(p)
Return type:

JGEXLine

distance(p)
Return type:

float

is_parallel(other)
Return type:

bool

is_perp(other)
Return type:

bool

is_same(other)
Return type:

bool

point_at(x=None, y=None)

Infer the point on the line by its x and/or y coordinate(s)

Return type:

Optional[JGEXPoint]

diff_side(p1, p2)
Return type:

bool

same_side(p1, p2)
Return type:

bool

sample_within(points, *, trials=5, rng)

Sample a point on the line within the boundary of existing points.

Return type:

JGEXPoint

angle()
Return type:

float

angle_to(other)
Return type:

float

class JGEXCircle(center=None, radius=None, p1=None, p2=None, p3=None)

Bases: JGEXGeometry

Numerical circle.

sample_within(points, *, trials=5, rng)

Sample a point on the circle.

Return type:

JGEXPoint

perpendicular_bisector(p1, p2)
Return type:

JGEXLine

solve_quad(a, b, c)

Solve a x^2 + bx + c = 0.

Return type:

tuple[float, ...]

intersect(a, b)
circle_circle_intersection(c1, c2, expected_points=None)

Returns a pair of Points as intersections of c1 and c2.

Return type:

tuple[JGEXPoint, ...]

line_circle_intersection(line, circle, expected_points=1)
Return type:

tuple[JGEXPoint, ...]

line_line_intersection(line_1, line_2, ensure_point=True)
Return type:

tuple[JGEXPoint, ...]

reduce_intersection(objs, existing_points, rng)

Reduce intersecting objects into one new point.

Return type:

list[JGEXPoint]