Geometries
- class PointNum(**data)
Bases:
BaseModel
This class contains the geometric coordinates of a point, and the functions needed to manipulate points as 2D vectors on the plane.
Its attributes are the x and y coordinates of the point, which are floats.
It contains the methods:
angle: returns the angle of the point with respect to the x-axis.
close_enough: checks if two points are close enough to be considered equal.
distance: computes the distance between the point and another point, line, or circle.
distance2: computes the squared distance between the point and another point, line, or circle.
rot90: returns a new point rotated 90 degrees counterclockwise.
rotatea: rotates the point by a given angle in radians.
rotate: rotates the point by given sine and cosine values.
flip: reflects the point across the y-axis.
perpendicular_line: returns a line perpendicular to a given line through this point.
foot: computes the closest point from this point on a line or circle.
parallel_line: returns a line parallel to a given line through this point.
dot: computes the dot product with another point as a vector.
deduplicate: class method to remove duplicate points from an iterable of points.
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
- dot(other)
- Return type:
float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class LineNum(**data)
Bases:
BaseModel
This class contains the numerical parameters of a line defined by the equation ax + by + c = 0.
Its only attribute is a tuple of three floats representing the coefficients (a, b, c) of the line equation.
It contains the methods for geometric manipulations of the line:
parallel_line: returns a line parallel to this line through a given point.
perpendicular_line: returns a line perpendicular to this line through a given point.
distance: computes the distance from a point to the line.
is_parallel: checks if this line is parallel to another line.
is_perp: checks if this line is perpendicular to another line.
is_same: checks if this line is the same as another line.
point_at: infers if a point is on the line by its x and/or y coordinate(s).
diff_side: checks if two points are on different sides of the line.
same_side: checks if two points are on the same side of the line.
angle: computes the angle of the line with respect to the x-axis.
angle_to: computes the angle between this line and another line.
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.
- coefficients: tuple[float, float, float]
- validate_coefficients()
- Return type:
Self
- 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
[PointNum
]
- diff_side(p1, p2)
- Return type:
bool
- same_side(p1, p2)
- Return type:
bool
- angle()
- Return type:
float
- angle_to(other)
- Return type:
float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class CircleNum(**data)
Bases:
BaseModel
This class contains the numerical parameters of a circle.
Its attributes are the center of the circle (a PointNum) and the radius (a float).
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.
- center: PointNum
- radius: float
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].