algolib.maths.geometry package
Submodules
algolib.maths.geometry.geometry module
A professional-grade \(N\)-dimensional geometry module.
It implements:
Point: a location in \(\mathbb{R}^N\).
Vector: a displacement in \(\mathbb{R}^N\).
Line: parametric line \(P(t) = P_0 + t\,d\).
Plane: hyperplane \(\{X:\; n\cdot(X-P_0)=0\}\).
GeometryUtils: utility routines.
All classes validate dimensions and numeric inputs, and raise
algolib.exceptions.InvalidTypeError
or
algolib.exceptions.InvalidValueError
on invalid usage.
- class algolib.maths.geometry.geometry.GeometryUtils[source]
Bases:
object
Common geometry utilities.
- class algolib.maths.geometry.geometry.Line(point: Point, direction: Vector)[source]
Bases:
object
Parametric line \(P(t) = P_0 + t\\,d\) in \(\\mathbb{R}^N\).
- Parameters:
- class algolib.maths.geometry.geometry.Plane(point: Point, normal: Vector)[source]
Bases:
object
Hyperplane \(\\{X:\\; n\\cdot(X-P_0)=0\\}\) in \(\\mathbb{R}^N\).
- Parameters:
- class algolib.maths.geometry.geometry.Point(coords: Sequence[int | float])[source]
Bases:
object
Point in \(N\)-dimensional Euclidean space.
- Parameters:
coords (Sequence[Number]) – Coordinates of the point; length defines the dimension.
Notes
A point has location but no direction or magnitude: \(P=(x_1,x_2,\\dots,x_N)\).
- class algolib.maths.geometry.geometry.Vector(comps: Sequence[int | float])[source]
Bases:
object
Vector in \(N\)-dimensional Euclidean space.
- Parameters:
comps (Sequence[Number]) – Components of the vector.
Notes
A vector represents both magnitude and direction.
- dot(other: Vector) float [source]
Return the dot product with another vector.
Formula
\(v\\cdot w = \\sum_i v_i w_i\).
- norm() float [source]
Return the Euclidean norm \(\lVert v \rVert = \sqrt{\sum_i v_i^2}\).
Notes
Non-finite inputs are handled explicitly: if any component is NaN, the result is NaN; if any component has infinite magnitude, the result is
inf
.Uses a scaling strategy for numerical stability to avoid overflow and underflow with mixed-magnitude components.