Geometries

class PointNum(x, y)

Bases: object

Numerical point.

angle()
Return type:

float

close_enough(point)
Return type:

bool

distance(p)
Return type:

float

distance2(p)
Return type:

float

rot90()
Return type:

PointNum

rotatea(ang)
Return type:

PointNum

rotate(sinb, cosb)
Return type:

PointNum

flip()
Return type:

PointNum

perpendicular_line(line)
Return type:

LineNum

foot(line)
Return type:

PointNum

parallel_line(line)
Return type:

LineNum

dot(other)
Return type:

float

classmethod deduplicate(points)
Return type:

list[PointNum]

intersect(obj)
Return type:

list[PointNum]

class FormNum

Bases: ABC

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

PointNum

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

Bases: FormNum

Numerical line.

parallel_line(p)
Return type:

LineNum

perpendicular_line(p)
Return type:

LineNum

same(other)
Return type:

bool

distance(p)
Return type:

float

is_parallel(other)
Return type:

bool

is_perp(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[PointNum]

diff_side(p1, p2)
Return type:

bool

same_side(p1, p2)
Return type:

bool

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

Sample a point within the boundary of points.

Return type:

PointNum

angle()
Return type:

float

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

Bases: FormNum

Numerical circle.

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

Sample a point within the boundary of points.

Return type:

PointNum

perpendicular_bisector(p1, p2)
Return type:

LineNum

exception InvalidIntersectError

Bases: Exception

exception InvalidReduceError

Bases: Exception

solve_quad(a, b, c)

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

Return type:

tuple[float, ...]

intersect(a, b)
circle_circle_intersection(c1, c2)

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

Return type:

tuple[PointNum, ...]

line_circle_intersection(line, circle)
Return type:

tuple[PointNum, ...]

circle_segment_intersect(circle, p1, p2)
Return type:

tuple[PointNum, ...]

line_line_intersection(line_1, line_2)
Return type:

tuple[PointNum, ...]

reduce(objs, existing_points, rng)

If all PointNum, then no touch. Else reduce intersecting objects into one point of intersections other than the existing points.

Return type:

tuple[PointNum, ...]