algolib.maths.geometry 包
子模块
algolib.maths.geometry.geometry 模块
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.Line(point: Point, direction: Vector)[源代码]
基类:
object
Parametric line \(P(t) = P_0 + t\\,d\) in \(\\mathbb{R}^N\).
- 参数:
- class algolib.maths.geometry.geometry.Plane(point: Point, normal: Vector)[源代码]
基类:
object
Hyperplane \(\\{X:\\; n\\cdot(X-P_0)=0\\}\) in \(\\mathbb{R}^N\).
- 参数:
- class algolib.maths.geometry.geometry.Point(coords: Sequence[int | float])[源代码]
基类:
object
Point in \(N\)-dimensional Euclidean space.
- 参数:
coords (Sequence[Number]) -- Coordinates of the point; length defines the dimension.
备注
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])[源代码]
基类:
object
Vector in \(N\)-dimensional Euclidean space.
- 参数:
comps (Sequence[Number]) -- 向量的分量。
备注
向量同时表示大小和方向。
- dot(other: Vector) float [源代码]
Return the dot product with another vector.
Formula
\(v\\cdot w = \\sum_i v_i w_i\).
- norm() float [源代码]
Return the Euclidean norm \(\lVert v \rVert = \sqrt{\sum_i v_i^2}\).
备注
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.