geometer package

geometer.utils package

geometer.utils.math.adjugate(A)[source]

Calculates the adjugate matrix of A.

The resulting matrix is defined by

\[\textrm{adj}(A)_{ij} = (-1)^{i+j} M_{j i},\]

where \(M_{j i}\) is the determinant of the submatrix of \(A\) obtained by deleting the j-th row and the i-th column of \(A\).

For small matrices, this function uses the following formula (Einstein notation):

\[\textrm{adj}(A)_{ij} = \frac{1}{(n-1)!} \varepsilon_{i\ i_2 \ldots i_n} \varepsilon_{j\ j_2 \ldots j_n} A_{j_2 i_2} \ldots A_{j_n i_n}\]

Source (German): https://de.wikipedia.org/wiki/Levi-Civita-Symbol#Zusammenhang_mit_der_Determinante

Parameters:A ((…, M, M) array_like) – The input matrix.
Returns:The adjugate of A.
Return type:(.., M, M) numpy.ndarray
geometer.utils.math.det(A)[source]

Computes the determinant of A.

Parameters:A ((…, M, M) array_like) – The input matrix.
Returns:The determinant of A.
Return type:(..) array_like
geometer.utils.math.hat_matrix(*args)[source]

Builds a skew symmetric matrix with the given scalars in the positions shown below.

\[\begin{split}\begin{pmatrix} 0 & c & -b\\ -c & 0 & a \\ b & -a & 0 \end{pmatrix}\end{split}\]
Parameters:a, b, c (float) – The scalars to use in the matrix.
Returns:The resulting antisymmetric matrix.
Return type:numpy.ndarray
geometer.utils.math.inv(A)[source]

Computes the inverse of A.

Parameters:A ((…, M, M) array_like) – The input matrix.
Returns:The inverse of A.
Return type:(.., M, M) numpy.ndarray
geometer.utils.math.is_multiple(a, b, axis=None, rtol=1e-05, atol=1e-08)[source]

Returns a boolean array where two arrays are scalar multiples of each other along a given axis.

For documentation of the tolerance parameters see numpy.isclose().

Parameters:
  • a, b (array_like) – Input arrays to compare.
  • axis (None or int or tuple of ints, optional) – The axis or axes along which the two arrays are compared. The default axis=None will compare the whole arrays and return only a single boolean value.
  • rtol (float, optional) – The relative tolerance parameter.
  • atol (float, optional) – The absolute tolerance parameter.
Returns:

Returns a boolean array of where along the given axis the arrays are a scalar multiple of each other (within the given tolerance). If no axis is given, returns a single boolean value.

Return type:

array_like

geometer.utils.math.matmul(a, b, transpose_a=False, transpose_b=False, adjoint_a=False, adjoint_b=False, **kwargs)[source]

Matrix product of two arrays.

Parameters:
  • a, b (array_like) – Input arrays, scalars not allowed.
  • transpose_a (bool) – If true, a is transposed before multiplication.
  • transpose_b (bool) – If true, b is transposed before multiplication.
  • adjoint_a (bool) – If true, a is conjugated and transposed before multiplication.
  • adjoint_b (bool) – If true, b is conjugated and transposed before multiplication.
  • **kwargs – Additional keyword arguments for numpy.matmul.
Returns:

The matrix product of the inputs.

Return type:

numpy.ndarray

geometer.utils.math.matvec(a, b, transpose_a=False, adjoint_a=False, **kwargs)[source]

Matrix-vector product of two arrays.

Parameters:
  • a, b (array_like) – Input arrays, scalars not allowed.
  • transpose_a (bool) – If true, a is transposed before multiplication.
  • adjoint_a (bool) – If true, a is conjugated and transposed before multiplication.
  • **kwargs – Additional keyword arguments for numpy.matmul.
Returns:

The matrix-vector product of the inputs.

Return type:

numpy.ndarray

geometer.utils.math.null_space(A, dim=None)[source]

Constructs an orthonormal basis for the null space of a A using SVD.

Parameters:
  • A ((…, M, N) array_like) – The input matrix.
  • dim (int or None, optional) – The dimension of the null space if previously known.
Returns:

Orthonormal basis for the null space of A (as column vectors in the returned matrix).

Return type:

(.., N, K) numpy.ndarray

geometer.utils.math.orth(A, dim=None)[source]

Constructs an orthonormal basis for the range of A using SVD.

Parameters:
  • A ((…, M, N) array_like) – The input matrix.
  • dim (int or None, optional) – The dimension of the image space if previously known.
Returns:

Orthonormal basis for the range of A (as column vectors in the returned matrix).

Return type:

(.., M, K) numpy.ndarray

geometer.utils.math.roots(p)[source]

Calculates the roots of a polynomial for the given coefficients.

The polynomial is defined as

\[p[0] x^n + p[1] x^{n-1} + \ldots + p[n-1] x + p[n].\]
Parameters:p (array_like) – The coefficients of the polynomial.
Returns:The roots of the polynomial.
Return type:array_like

geometer.base module

class geometer.base.KroneckerDelta(n, p=1)[source]

Bases: geometer.base.Tensor

This class can be used to construct a (p, p)-tensor representing the Kronecker delta tensor.

The following generalized definition of the Kronecker delta is used:

\[\begin{split}\delta_{\nu_{1} \ldots \nu_{p}}^{\mu_{1} \ldots \mu_{p}} = \begin{cases} +1 & \text{ if } (\nu_{1}, \ldots, \nu_{p}) \text{ are an even permutation of } (\mu_{1}, \ldots, \mu_{p})\\ -1 & \text{ if } (\nu_{1}, \ldots, \nu_{p}) \text{ are an odd permutation of } (\mu_{1}, \ldots, \mu_{p})\\ 0 & \text{ else} \end{cases}\end{split}\]
Parameters:
  • n (int) – The dimension of the tensor.
  • p (int, optional) – The number of covariant and contravariant indices of the tensor, default is 1.

References

[1]https://en.wikipedia.org/wiki/Kronecker_delta#Generalizations
class geometer.base.LeviCivitaTensor(size, covariant=True)[source]

Bases: geometer.base.Tensor

This class can be used to construct a tensor representing the Levi-Civita symbol.

The Levi-Civita symbol is also called \(\varepsilon\)-Tensor and is defined as follows:

\[\begin{split}\varepsilon_{\nu_{1} \ldots \nu_{n}} = \begin{cases} +1 & \text{ if } (\nu_{1}, \ldots, \nu_{n}) \text{ are an even permutation of } (1, \ldots, n)\\ -1 & \text{ if } (\nu_{1}, \ldots, \nu_{n}) \text{ are an odd permutation of } (1, \ldots, n)\\ 0 & \text{ else} \end{cases}\end{split}\]
Parameters:
  • size (int) – The number of indices of the tensor.
  • covariant (bool, optional) – If true, the tensor will only have covariant indices. Default: True

References

[1]https://en.wikipedia.org/wiki/Levi-Civita_symbol#Generalization_to_n_dimensions
class geometer.base.ProjectiveCollection(elements, *, covariant=True, tensor_rank=1, **kwargs)[source]

Bases: geometer.base.TensorCollection, abc.ABC

Base class for collections of projective elements.

dim

The ambient dimension tensors in the collection.

Type:int
class geometer.base.ProjectiveElement(*args, covariant=True, tensor_rank=None, **kwargs)[source]

Bases: geometer.base.Tensor, abc.ABC

Base class for all projective tensors, i.e. all objects that identify scalar multiples.

dim

The ambient dimension of the tensor.

Type:int
class geometer.base.Tensor(*args, covariant=True, tensor_rank=None, **kwargs)[source]

Bases: object

Wrapper class around a numpy array that keeps track of covariant and contravariant indices.

Covariant indices are the lower indices (subscripts) and contravariant indices are the upper indices (superscripts) of a tensor (see [1]).

Parameters:
  • *args – Either a single iterable or multiple coordinate numbers.
  • covariant (bool or list of int, optional) – If False, all indices are contravariant. If a list of indices indices is supplied, the specified indices of the array will be covariant indices and all others contravariant indices. By default all indices are covariant.
  • tensor_rank (int or None, optional) – If the object contains multiple tensors, this parameter specifies the rank of the tensors contained in the collection. By default only a single tensor is contained in a Tensor object.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
array

The underlying numpy array.

Type:numpy.ndarray

References

[1]https://en.wikipedia.org/wiki/Ricci_calculus#Upper_and_lower_indices
T

The transposed tensor, same as self.transpose().

copy()[source]
dtype

The dtype of the underlying numpy array, same as self.array.dtype.

Type:numpy.dtype
is_zero(tol=1e-08)[source]

Test whether the tensor is zero with respect to covariant and contravariant indices.

Parameters:tol (float, optional) – The accepted tolerance.
Returns:True if the tensor is zero. If there are more indices than the covariant and contravariant indices, a boolean array is returned.
Return type:bool
rank

The rank of the Tensor, same as self.array.ndim.

Type:int
shape

The shape of the underlying numpy array, same as self.array.shape.

Type:tuple of int
tensor_product(other)[source]

Return a new tensor that is the tensor product of this and the other tensor.

This method will also reorder the indices of the resulting tensor, to ensure that covariant indices are in front of the contravariant indices.

Parameters:other (Tensor) – The other tensor.
Returns:The tensor product.
Return type:Tensor
tensor_shape

The shape or type of the tensor, the first number is the number of covariant indices, the second the number of contravariant indices.

Type:tuple of int
transpose(perm=None)[source]

Permute the indices of the tensor.

Parameters:perm (tuple of int, optional) – A list of permuted indices or a shorter list representing a permutation in cycle notation. By default, the indices are reversed.
Returns:The tensor with permuted indices.
Return type:Tensor
class geometer.base.TensorCollection(elements, *, covariant=True, tensor_rank=1, **kwargs)[source]

Bases: geometer.base.Tensor

A collection of Tensor objects with identical covariant/contravariant indices and shape stored in a tensor.

Parameters:
  • elements (array_like) – A (nested) sequence of Tensor objects, a numpy array, a Tensor or a (nested) sequence of numbers. If the sequence contains Tensor objects, they must all have the same shape and the same covariant/contravariant indices.
  • covariant (bool or list of int, optional) – This parameter is used when elements is a general array or sequence of numbers, to determine the covariant indices of tensors contained in the collection. If False, all indices of all tensors in the collection are contravariant. If instead a sequence of indices is supplied, the specified indices of all tensors in the collection will be covariant indices and the rest of the indices of each tensor will be contravariant. By default all indices are covariant.
  • tensor_rank (int, optional) – The rank of the tensors contained in the collection. This parameter is only used if elements is not a sequence of Tensor objects or a single tensor. Default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
expand_dims(axis)[source]

Add a new index to the collection.

Parameters:axis (int) – Position in the new shape where the new axis is placed.
Returns:The tensor collection with an additional index.
Return type:TensorCollection
flat

A flat iterator of the collection that yields Tensor objects.

Type:generator
size

The number of tensors in the collection.

Type:int
class geometer.base.TensorDiagram(*edges)[source]

Bases: object

A class used to specify and calculate tensor diagrams (also called Penrose Graphical Notation).

Each edge in the diagram represents a contraction of two indices of the tensors connected by that edge. In Einstein-notation that would mean that an edge from tensor A to tensor B is equivalent to the expression \(A_{i j}B^{i k}_l\), where \(j, k, l\) are free indices. The indices to contract are chosen from front to back from contravariant and covariant indices of the tensors that are connected by an edge.

Parameters:*edges – Variable number of tuples, that represent the edge from one tensor to another.

References

[1]https://www-m10.ma.tum.de/foswiki/pub/Lehrstuhl/PublikationenJRG/52_TensorDiagrams.pdf
[2]
  1. Richter-Gebert: Perspectives on Projective Geometry, Chapters 13-14
add_edge(source, target)[source]

Add an edge to the diagram.

Parameters:
  • source (Tensor) – The source tensor of the edge in the diagram.
  • target (Tensor) – The target tensor of the edge in the diagram.
add_node(node)[source]

Add a node to the tensor diagram without adding an edge/contraction.

A diagram of nodes where none are connected is equivalent to calculating the tensor product with the method Tensor.tensor_product().

Parameters:node (Tensor) – The node to add.
calculate()[source]

Calculates the result of the diagram.

Returns:The tensor resulting from the specified tensor diagram.
Return type:Tensor
copy()[source]

geometer.curve module

class geometer.curve.Circle(center=Point(0, 0), radius=1, **kwargs)[source]

Bases: geometer.curve.Ellipse

A circle in 2D.

Parameters:
  • center (Point, optional) – The center point of the circle, default is Point(0, 0).
  • radius (float, optional) – The radius of the circle, default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
area

The area of the circle.

Type:float
center

The center of the circle.

Type:Point
intersection_angle(other)[source]

Calculates the angle of intersection of two circles using its Lie coordinates.

Parameters:other (Circle) – The circle to intersect this circle with.
Returns:The angle of intersection.
Return type:float

References

[1]https://en.wikipedia.org/wiki/Lie_sphere_geometry
lie_coordinates

The Lie coordinates of the circle as point in RP4.

Type:Point
radius

The radius of the circle.

Type:float
class geometer.curve.Cone(vertex=Point(0, 0, 0), base_center=Point(0, 0, 1), radius=1, **kwargs)[source]

Bases: geometer.curve.Quadric

A quadric that forms a circular double cone in 3D.

Parameters:
  • vertex (Point, optional) – The vertex or apex of the cone. Default is (0, 0, 0).
  • base_center (Point, optional) – The center of the circle that forms the base of the cone. Default is (0, 0, 1)
  • radius (float, optional) – The radius of the circle forming the base of the cone. Default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
class geometer.curve.Conic(matrix, is_dual=False, normalize_matrix=False, **kwargs)[source]

Bases: geometer.curve.Quadric

A two-dimensional conic.

foci

The foci of the conic.

Type:tuple of Point
classmethod from_crossratio(cr, a, b, c, d)[source]

Construct a conic from a cross ratio and four other points.

This method relies on the fact that a point lies on a conic with five other points, if and only of the cross ratio seen from this point is the same as the cross ratio of four of the other points seen from the fifth point.

Parameters:
  • cr (float) – The crossratio of the other points that defines the conic.
  • a, b, c, d (Point) – The points lying on the conic.
Returns:

The resulting conic.

Return type:

Conic

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 10.2
classmethod from_foci(f1, f2, bound)[source]

Construct a conic with the given focal points that passes through the boundary point.

Parameters:
  • f1, f2 (Point) – The two focal points.
  • bound (Point) – A boundary point that lies on the conic.
Returns:

The resulting conic.

Return type:

Conic

classmethod from_lines(g, h)[source]

Construct a degenerate conic from two lines.

Parameters:g, h (Line) – The two lines the conic consists of.
Returns:The resulting conic.
Return type:Conic
classmethod from_points(a, b, c, d, e)[source]

Construct a conic through five points.

Parameters:a, b, c, d, e (Point) – The points lying on the conic.
Returns:The resulting conic.
Return type:Conic
classmethod from_tangent(tangent, a, b, c, d)[source]

Construct a conic through four points and tangent to a line.

Parameters:
  • tangent (Line)
  • a, b, c, d (Point) – The points lying on the conic.
Returns:

The resulting conic.

Return type:

Conic

intersect(other)[source]

Calculates points of intersection with the conic.

Parameters:other (Line, LineCollection or Conic) – The object to intersect this conic with.
Returns:The points of intersection.
Return type:list of Point or list of PointCollection

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 11.4
polar(pt)[source]

Calculates the polar line of the conic at a given point.

Parameters:pt (Point) – The point to calculate the polar at.
Returns:The polar line.
Return type:Line
tangent(at)[source]

Calculates the tangent line at a given point or the tangent lines between a point and the conic.

Parameters:at (Point) – The point to calculate the tangent at.
Returns:The tangent line(s).
Return type:Line or tuple of Line
class geometer.curve.Cylinder(center=Point(0, 0, 0), direction=Point(0, 0, 1), radius=1, **kwargs)[source]

Bases: geometer.curve.Cone

An infinite circular cylinder in 3D.

Parameters:
  • center (Point, optional) – The center of the cylinder. Default is (0, 0, 0).
  • direction (Point) – The direction of the axis of the cylinder. Default is (0, 0, 1).
  • radius (float, optional) – The radius of the cylinder. Default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
class geometer.curve.Ellipse(center=Point(0, 0), hradius=1, vradius=1, **kwargs)[source]

Bases: geometer.curve.Conic

Represents an ellipse in 2D.

Parameters:
  • center (Point, optional) – The center of the ellipse, default is Point(0, 0).
  • hradius (float, optional) – The horizontal radius (along the x-axis), default is 1.
  • vradius (float, optional) – The vertical radius (along the y-axis), default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
class geometer.curve.Quadric(matrix, is_dual=False, normalize_matrix=False, **kwargs)[source]

Bases: geometer.base.ProjectiveElement

Represents a quadric, i.e. the zero set of a polynomial of degree 2, in any dimension.

The quadric is defined by a symmetric matrix of size \(n+1\) where \(n\) is the dimension of the projective space. If \(A \in \mathbb{R}^{(n+1) \times (n+1)}\), the quadric contains all points \(x \in \mathbb{R}^{n+1}\) such that \(x^T A x = 0\).

Parameters:
  • matrix (array_like or Tensor) – A two-dimensional array defining the (n+1)x(n+1) symmetric matrix of the quadric.
  • is_dual (bool, optional) – If true, the quadric represents a dual quadric, i.e. all hyperplanes tangent to the non-dual quadric.
  • normalize_matrix (bool, optional) – If true, normalize matrix using the (n+1)-th root of the absolute value of its pseudo-determinant.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
is_dual

True if the quadric is a dual quadric i.e. contains all hyperplanes tangent to the non-dual quadric.

Type:bool
components

The components of a degenerate quadric.

Type:list of ProjectiveElement
contains(other, tol=1e-08)[source]

Tests if a given point lies on the quadric.

Parameters:
  • other (Point or Subspace) – The point or hyperplane to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True if the quadric contains the point.

Return type:

bool

dual

The dual quadric.

Type:Quadric
classmethod from_planes(e, f)[source]

Construct a degenerate quadric from two hyperplanes.

Parameters:e, f (Plane) – The two planes the quadric consists of.
Returns:The resulting quadric.
Return type:Quadric
intersect(other)[source]

Calculates points of intersection of a line with the quadric.

This method also returns complex points of intersection, even if the quadric and the line do not intersect in any real points.

Parameters:other (Line or LineCollection) – The line to intersect this quadric with.
Returns:The points of intersection.
Return type:list of Point or list of PointCollection

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 11.3
is_degenerate

True if the quadric is degenerate.

Type:bool
is_tangent(plane)[source]

Tests if a given hyperplane is tangent to the quadric.

Parameters:plane (Subspace) – The hyperplane to test.
Returns:True if the given hyperplane is tangent to the quadric.
Return type:bool
tangent(at)[source]

Returns the hyperplane defining the tangent space at a given point.

Parameters:at (Point) – A point on the quadric at which the tangent plane is calculated.
Returns:The tangent plane at the given point.
Return type:Plane
class geometer.curve.QuadricCollection(matrices, is_dual=False, **kwargs)[source]

Bases: geometer.base.ProjectiveCollection

A collection of quadrics or conics.

components

The components of the degenerate quadrics.

Type:list of ProjectiveCollection
contains(other, tol=1e-08)[source]

Tests if a given point lies on the quadrics.

Parameters:
  • other (Point, PointCollection, Subspace or SubspaceCollection) – The points to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

Returns a boolean array of which quadrics contain the points.

Return type:

numpy.ndarray

dual

The dual quadrics of the quadrics in the collection.

Type:QuadricCollection
intersect(other)[source]

Calculates points of intersection of a line or a collection of lines with the quadrics.

Parameters:other (Line or LineCollection) – The line or lines to intersect the quadrics with.
Returns:The points of intersection
Return type:list of PointCollection
is_degenerate

Boolean array of which quadrics are degenerate in the collection.

Type:numpy.ndarray
is_tangent(planes)[source]

Tests if a given hyperplane is tangent to the quadrics.

Parameters:planes (Subspace or SubspaceCollection) – The hyperplane to test.
Returns:Returns a boolean array of which hyperplanes are tangent to the quadrics.
Return type:numpy.ndarray
tangent(at)[source]

Returns the hyperplanes defining the tangent spaces at given points.

Parameters:at (Point or PointCollection) – A point on the quadric at which the tangent plane is calculated.
Returns:The tangent planes at the given points.
Return type:PlaneCollection
class geometer.curve.Sphere(center=Point(0, 0, 0), radius=1, **kwargs)[source]

Bases: geometer.curve.Quadric

A sphere in any dimension.

Parameters:
  • center (Point, optional) – The center of the sphere, default is Point(0, 0, 0).
  • radius (float, optional) – The radius of the sphere, default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
area

The surface area of the sphere.

Type:float
center

The center of the sphere.

Type:Point
radius

The radius of the sphere.

Type:float
volume

The volume of the sphere.

Type:float

geometer.exceptions module

exception geometer.exceptions.GeometryException[source]

Bases: Exception

A general geometric error occurred.

exception geometer.exceptions.IncidenceError[source]

Bases: geometer.exceptions.GeometryException, ValueError

The given objects were not incident to each other.

exception geometer.exceptions.LinearDependenceError(message, dependent_values=True)[source]

Bases: geometer.exceptions.GeometryException, ValueError

The given values were linearly dependent, making the computation impossible.

exception geometer.exceptions.NotCollinear[source]

Bases: geometer.exceptions.GeometryException, ValueError

The given values are not collinear.

exception geometer.exceptions.NotCoplanar[source]

Bases: geometer.exceptions.GeometryException, ValueError

The given values are not coplanar.

exception geometer.exceptions.NotReducible[source]

Bases: geometer.exceptions.GeometryException, ValueError

The given geometric object is not reducible.

exception geometer.exceptions.TensorComputationError[source]

Bases: geometer.exceptions.GeometryException

An error during a tensor computation occurred.

geometer.operators module

geometer.operators.angle(*args)[source]

Calculates the (oriented) angle between given points, lines or planes.

The function uses the Laguerre formula to calculate angles in two or three dimensional projective space using cross ratios. To calculate the angle between two planes, two additional planes tangent to the absolute conic are constructed (see [1]).

Since the Laguerre formula uses the complex logarithm (which gives values between \(-\pi i\) and \(\pi i\)) and multiplies it with \(1/2i\), this function can only calculate angles between \(-\pi / 2\) and \(\pi / 2\).

The sign of the angle is determined by the order of the arguments. The points passed to the cross ratio are in the same order as the arguments to this function. When three points are given as arguments, the first point is the point at which the angle is calculated.

Parameters:*args – The objects between which the function calculates the angle. This can be 2 or 3 points, 2 lines or 2 planes.
Returns:The oriented angle(s) between the given objects.
Return type:array_like

References

[1]Olivier Faugeras, Three-dimensional Computer Vision, Page 30
geometer.operators.angle_bisectors(l, m)[source]

Constructs the angle bisectors of two given lines.

Parameters:l, m (Line, LineCollection) – Two lines in any dimension.
Returns:The two angle bisectors.
Return type:tuple of Line or tuple of LineCollection
geometer.operators.crossratio(a, b, c, d, from_point=None)[source]

Calculates the cross ratio of points or lines.

Parameters:
  • a, b, c, d (Point, PointCollection, Line, LineCollection, Plane or PlaneCollection) – The points, lines or planes (any dimension) to calculate the cross ratio of.
  • from_point (Point or PointCollection, optional) – A 2D point, only accepted if the other arguments are also 2D points.
Returns:

The cross ratio(s) of the given objects.

Return type:

array_like

geometer.operators.dist(p, q)[source]

Calculates the (euclidean) distance between two objects.

Instead of the usual formula for the euclidean distance this function uses the following formula that is projectively invariant (in P and Q):

\[\textrm{dist}(P, Q) = 4 \left|\frac{\sqrt{[P, Q, I][P, Q, J]}}{[P, I, J][Q, I, J]}\right|\]
Parameters:p, q (Point, Line, Plane or Polygon) – The points, lines or planes to calculate the distance between.
Returns:The distance between the given objects.
Return type:array_like

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 18.8
geometer.operators.harmonic_set(a, b, c)[source]

Constructs a fourth point that forms a harmonic set with the given points.

The three given points must be collinear.

If the returned point is d, the points {{a, b}, {c, d}} will be in harmonic position.

Parameters:a, b, c (Point or PointCollection) – The points (any dimension) that are used to construct the fourth point in the harmonic set.
Returns:The point that forms a harmonic set with the given points.
Return type:Point or PointCollection
geometer.operators.is_cocircular(a, b, c, d, rtol=1e-15, atol=1e-08)[source]

Tests whether four points lie on a circle.

Parameters:
  • a, b, c, d (Point) – Four points in RP2 or CP1.
  • rtol (float, optional) – The relative tolerance parameter.
  • atol (float, optional) – The absolute tolerance parameter.
Returns:

True if the four points lie on a circle.

Return type:

array_like

geometer.operators.is_collinear(*args, tol=1e-08)[source]

Tests whether the given points or lines are collinear, coplanar or concurrent. Works in any dimension.

Due to line point duality this function has dual versions is_collinear and is_concurrent.

Parameters:
  • *args – The points or lines to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True if the given points are coplanar (in 3D) or collinear (in 2D) or if the given lines are concurrent.

Return type:

array_like

geometer.operators.is_concurrent(*args, tol=1e-08)[source]

Tests whether the given points or lines are collinear, coplanar or concurrent. Works in any dimension.

Due to line point duality this function has dual versions is_collinear and is_concurrent.

Parameters:
  • *args – The points or lines to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True if the given points are coplanar (in 3D) or collinear (in 2D) or if the given lines are concurrent.

Return type:

array_like

geometer.operators.is_coplanar(*args, tol=1e-08)[source]

Tests whether the given points or lines are collinear, coplanar or concurrent. Works in any dimension.

Due to line point duality this function has dual versions is_collinear and is_concurrent.

Parameters:
  • *args – The points or lines to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True if the given points are coplanar (in 3D) or collinear (in 2D) or if the given lines are concurrent.

Return type:

array_like

geometer.operators.is_perpendicular(l, m, rtol=1e-15, atol=1e-08)[source]

Tests whether two lines/planes are perpendicular.

Parameters:
  • l, m (Line, LineCollection, Plane or PlaneCollection) – Two lines in any dimension or two planes in 3D.
  • rtol (float, optional) – The relative tolerance parameter.
  • atol (float, optional) – The absolute tolerance parameter.
Returns:

True if the two lines/planes are perpendicular.

Return type:

array_like

geometer.point module

class geometer.point.Line(*args, **kwargs)[source]

Bases: geometer.point.Subspace

Represents a line in a projective space of arbitrary dimension.

Parameters:
  • *args – Two points or the coordinates of the line. Instead of all coordinates separately, a single iterable can also be supplied.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
base_point

A base point for the line, arbitrarily chosen.

Type:Point
basis_matrix

A matrix with orthonormal basis vectors as rows.

Type:numpy.ndarray
contravariant_tensor

The contravariant version of a line in 3D.

Type:Line
covariant_tensor

The covariant version of a line in 3D.

Type:Line
direction

The direction of the line (not normalized).

Type:Point
is_coplanar(other)[source]

Tests whether another line lies in the same plane as this line, i.e. whether two lines intersect.

Parameters:other (Line) – A line in 3D to test.
Returns:True if the two lines intersect (i.e. they lie in the same plane).
Return type:bool

References

[1]Jim Blinn, Lines in Space: Back to the Diagrams, Line Intersections
lie_coordinates

The Lie coordinates of a line in 2D.

Type:Point
mirror(pt)[source]

Construct the reflection of a point at this line.

Parameters:pt (Point, PointCollection) – The point(s) to reflect.
Returns:The mirror point(s).
Return type:Point or PointCollection

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 19.1
perpendicular(through, plane=None)[source]

Construct the perpendicular line though a point.

Parameters:
  • through (Point, PointCollection) – The point through which the perpendicular is constructed.
  • plane (Plane, optional) – In three or higher dimensional spaces, the plane in which the perpendicular line is supposed to lie can be specified.
Returns:

The perpendicular line.

Return type:

Line

project(pt)[source]

The orthogonal projection of a point onto the line.

Parameters:pt (Point, PointCollection) – The point(s) to project.
Returns:The projected point(s).
Return type:Point or PointCollection
class geometer.point.LineCollection(*args, **kwargs)[source]

Bases: geometer.point.SubspaceCollection

A collection of lines.

Parameters:
  • *args – Two collections of points or a (nested) sequence of line coordinates.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
base_point

Base points for the lines, arbitrarily chosen.

Type:PointCollection
contravariant_tensor

The contravariant tensors of lines in 3D.

Type:LineCollection
covariant_tensor

The covariant tensors of lines in 3D.

Type:LineCollection
direction

The direction of the lines (not normalized).

Type:PointCollection
mirror(pt)[source]

Construct the reflection of points at the lines.

Parameters:pt (Point, PointCollection) – The point to reflect.
Returns:The mirror points.
Return type:PointCollection

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Section 19.1
perpendicular(through, plane=None)[source]

Construct the perpendicular line though a point.

Parameters:
  • through (Point, PointCollection) – The point through which the perpendicular is constructed.
  • plane (Plane, PlaneCollection, optional) – In three or higher dimensional spaces, the planes in which the perpendicular lines are supposed to lie can be specified.
Returns:

The perpendicular lines.

Return type:

LineCollection

project(pt)[source]

The orthogonal projection of points onto the lines.

Parameters:pt (Point, PointCollection) – The points to project.
Returns:The projected points.
Return type:PointCollection
class geometer.point.Plane(*args, **kwargs)[source]

Bases: geometer.point.Subspace

Represents a hyperplane in a projective space of arbitrary dimension.

Parameters:
  • *args – The points/lines spanning the plane or the coordinates of the hyperplane. Instead of separate coordinates, a single iterable can be supplied.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
basis_matrix

A matrix with orthonormal basis vectors as rows.

Type:numpy.ndarray
mirror(pt)[source]

Construct the reflection of a point at this plane.

Only works in 3D.

Parameters:pt (Point, PointCollection) – The point(s) to reflect.
Returns:The mirror point(s).
Return type:Point or PointCollection
perpendicular(through)[source]

Construct the perpendicular line though a point or the perpendicular plane through a line.

Only works in 3D.

Parameters:through (Point, PointCollection, Line, LineCollection) – The point(s) or line(s) through which the perpendicular is constructed.
Returns:The perpendicular line(s) or plane(s).
Return type:Line, LineCollection, Plane or PlaneCollection
project(pt)[source]

The orthogonal projection of a point onto the plane.

Only works in 3D.

Parameters:pt (Point, PointCollection) – The point(s) to project.
Returns:The projected point(s).
Return type:Point or PointCollection
class geometer.point.PlaneCollection(*args, **kwargs)[source]

Bases: geometer.point.SubspaceCollection

A collection of planes.

Parameters:
  • *args – The collections of points/lines spanning the planes or the coordinates of multiple hyperplanes.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
basis_matrix
mirror(pt)[source]

Construct the reflections of points at the planes.

Only works in 3D.

Parameters:pt (Point, PointCollection) – The points to reflect.
Returns:The mirror points.
Return type:PointCollection
perpendicular(through)[source]

Construct the perpendicular lines though the given points or the perpendicular planes through the given lines.

Only works in 3D.

Parameters:through (Point, PointCollection, Line, LineCollection) – The points or lines through which the perpendiculars are constructed.
Returns:The perpendicular lines or planes.
Return type:LineCollection or PlaneCollection
project(pt)[source]

The orthogonal projection of points onto the planes.

Only works in 3D.

Parameters:pt (Point, PointCollection) – The points to project.
Returns:The projected points.
Return type:PointCollection
class geometer.point.Point(*args, **kwargs)[source]

Bases: geometer.base.ProjectiveElement

Represents points in a projective space of arbitrary dimension.

The number of supplied coordinates determines the dimension of the space that the point lives in. If the coordinates are given as arguments (not in a single iterable), the coordinates will automatically be transformed into homogeneous coordinates, i.e. a one added as an additional coordinate.

Addition and subtraction of finite and infinite points will always give a finite result if one of the points was finite beforehand.

Parameters:
  • *args – A single iterable object or tensor or multiple (affine) coordinates.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
isinf

true if the point lies at infinity i.e. the last coordinate is zero.

Type:bool
isreal

true if the point is real, i.e. the imaginary part is zero for all components.

Type:bool
join(*others)[source]

Execute the join of this point with other objects.

Parameters:*others – The objects to join the point with.
Returns:The result of the join operation.
Return type:Subspace

See also

join()

lie_coordinates

The Lie coordinates of a point in 2D.

Type:Point
normalized_array

The coordinate array of the point with the last coordinate normalized to one.

Type:numpy.ndarray
class geometer.point.PointCollection(elements, *, homogenize=False, **kwargs)[source]

Bases: geometer.base.ProjectiveCollection

A collection of points.

Parameters:
  • elements (array_like) – A (nested) sequence of points or a numpy array that contains the coordinates of multiple points.
  • homogenize (bool, optional) – If True, all points in the array will be converted to homogeneous coordinates, i.e. 1 will be added to the coordinates of each point in elements. By default homogenize is False.
isinf

Boolean array that indicates which points lie at infinity.

Type:array_like
isreal

Boolean array that indicates which points are real.

Type:array_like
join(*others)[source]
normalized_array

The coordinate array of the points with the last coordinates normalized to 1.

Type:numpy.ndarray
class geometer.point.Subspace(*args, **kwargs)[source]

Bases: geometer.base.ProjectiveElement

Represents a general subspace of a projective space. Line and Plane are subclasses.

Parameters:
  • *args – The coordinates of the subspace. Instead of separate coordinates, a single iterable can be supplied.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
basis_matrix

A matrix with orthonormal basis vectors as rows.

Type:numpy.ndarray
contains(other, tol=1e-08)[source]

Tests whether a given point or line lies in the subspace.

Parameters:
  • other (Point or Line) – The object to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True, if the given point/line lies in the subspace.

Return type:

bool

general_point

A point in general position i.e. not in the subspace, to be used in geometric constructions.

Type:Point
is_parallel(other)[source]

Tests whether a given subspace is parallel to this subspace.

Parameters:other (Subspace) – The other space to test.
Returns:True, if the two spaces are parallel.
Return type:bool
join(*others)[source]

Execute the join of the subspace with other objects.

Parameters:*others – The objects to join the subspace with.
Returns:The result of the join operation.
Return type:Subspace

See also

join()

meet(*others)[source]

Intersect the subspace with other objects.

Parameters:*others – The objects to intersect the subspace with.
Returns:The result of the meet operation.
Return type:Point or Subspace

See also

meet()

parallel(through)[source]

Returns the subspace through a given point that is parallel to this subspace.

Parameters:through (Point) – The point through which the parallel subspace is to be constructed.
Returns:The parallel subspace.
Return type:Subspace
class geometer.point.SubspaceCollection(elements, *, tensor_rank=1, **kwargs)[source]

Bases: geometer.base.ProjectiveCollection

A collection of subspaces.

Parameters:
  • elements (array_like) – A sequence of Subspace objects, a numpy array, a Tensor or a (nested) sequence of numbers.
  • tensor_rank (int, optional) – The rank of the tensors contained in the collection. Default is 1.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
basis_matrix
contains(other, tol=1e-08)[source]

Tests whether given points or lines lie in the subspaces.

Parameters:
  • other (Point, PointCollection, Line or LineCollection) – The object(s) to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

Boolean array that indicates which of given points/lines lies in the subspaces.

Return type:

array_like

general_point

Points in general position i.e. not in the subspaces.

Type:PointCollection
join(*others)[source]
meet(other)[source]
parallel(through)[source]

Returns the subspaces through given points that are parallel to this collection of subspaces.

Parameters:through (Point or PointCollection) – The point through which the parallel subspaces are to be constructed.
Returns:The parallel subspaces.
Return type:SubspaceCollection
geometer.point.infty_hyperplane(dimension)[source]
geometer.point.join(*args, _check_dependence=True, _normalize_result=True)[source]

Joins a number of objects to form a line, plane or subspace.

Parameters:*args – Objects to join, e.g. 2 points, lines, a point and a line or 3 points.
Returns:The resulting line, plane or subspace.
Return type:Subspace or SubspaceCollection
geometer.point.meet(*args, _check_dependence=True, _normalize_result=True)[source]

Intersects a number of given objects.

Parameters:*args – Objects to intersect, e.g. two lines, planes, a plane and a line or 3 planes.
Returns:The resulting point, line or subspace.
Return type:Point, PointCollection, Subspace or SubspaceCollection

geometer.shapes module

class geometer.shapes.Cuboid(a, b, c, d, **kwargs)[source]

Bases: geometer.shapes.Polyhedron

A class that can be used to construct a cuboid/box or a cube.

Parameters:
  • a (Point) – The base point of the cuboid.
  • b (Point) – The vertex that determines the first direction of the edges.
  • c (Point) – The vertex that determines the second direction of the edges.
  • d (Point) – The vertex that determines the third direction of the edges.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
class geometer.shapes.Polygon(*args, **kwargs)[source]

Bases: geometer.shapes.Polytope

A flat polygon with vertices in any dimension.

The vertices of the polygon must be given either in clockwise or counterclockwise order.

Parameters:
  • *args – The coplanar points that are the vertices of the polygon. They will be connected sequentially by line segments.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
angles

The interior angles of the polygon.

Type:list of float
area

The area of the polygon.

Type:float
centroid

The centroid (center of mass) of the polygon.

Type:Point
contains(other)[source]

Tests whether a point is contained in the polygon.

Points on an edge of the polygon are considered True.

Parameters:other (Point or PointCollection) – The point to test.
Returns:True if the point is contained in the polygon.
Return type:array_like

References

[1]http://paulbourke.net/geometry/polygonmesh/#insidepoly
edges

The edges of the polygon.

Type:SegmentCollection
facets

The facets of the polytope.

Type:list of Polytope
intersect(other)[source]

Intersect the polygon with another object.

Parameters:other (Line or Segment) – The object to intersect the polygon with.
Returns:The points of intersection.
Return type:list of Point
vertices

The vertices of the polytope.

Type:list of Point
class geometer.shapes.PolygonCollection(*args, **kwargs)[source]

Bases: geometer.point.PointCollection

A collection of polygons with the same number of vertices.

Parameters:
  • *args – The collections of points that define the vertices of the polygons or a (nested) sequence of vertex coordinates.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
area

The areas of the polygons.

Type:array_like
contains(other)[source]

Tests whether a point or a collection of points is contained in the polygons.

Parameters:other (Point or PointCollection) – The points to test. If more than one point is given, the shape of the collection must be compatible with the shape of the polygon collection.
Returns:Returns a boolean array of which points are contained in the polygons.
Return type:numpy.ndarray
edges

The edges of the polygons in the collection.

Type:SegmentCollection
expand_dims(axis)[source]

Add a new index to the collection.

Parameters:axis (int) – Position in the new shape where the new axis is placed.
Returns:The tensor collection with an additional index.
Return type:TensorCollection
intersect(other)[source]

Intersect the polygons with a line, line segment or a collection of lines.

Parameters:other (Line, Segment, LineCollection or SegmentCollection) – The object to intersect the polygon with.
Returns:The points of intersection.
Return type:PointCollection
vertices

The vertices of the polygons.

Type:list of PointCollection
class geometer.shapes.Polyhedron(*args, **kwargs)[source]

Bases: geometer.shapes.Polytope

A class representing polyhedra (3-polytopes).

area

The surface area of the polyhedron.

Type:float
edges

The edges of the polyhedron.

Type:list of Segment
faces

The faces of the polyhedron.

Type:PolygonCollection
intersect(other)[source]

Intersect the polyhedron with another object.

Parameters:other (Line or Segment) – The object to intersect the polyhedron with.
Returns:The points of intersection.
Return type:list of Point
class geometer.shapes.Polytope(*args, **kwargs)[source]

Bases: geometer.point.PointCollection

A class representing polytopes in arbitrary dimension. A (n+1)-polytope is a collection of n-polytopes that have some (n-1)-polytopes in common, where 3-polytopes are polyhedra, 2-polytopes are polygons and 1-polytopes are line segments.

The polytope is stored as a multidimensional numpy array. Hence, all facets of the polytope must have the same number of vertices and facets.

Parameters:
  • *args – The polytopes defining the facets ot the polytope.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
array

The underlying numpy array.

Type:numpy.ndarray
facets

The facets of the polytope.

Type:list of Polytope
vertices

The vertices of the polytope.

Type:list of Point
class geometer.shapes.Rectangle(*args, **kwargs)[source]

Bases: geometer.shapes.Polygon

A class representing rectangles.

Parameters:
  • a (Point)
  • b (Point)
  • c (Point)
  • d (Point)
class geometer.shapes.RegularPolygon(center, radius, n, axis=None, **kwargs)[source]

Bases: geometer.shapes.Polygon

A class that can be used to construct regular polygon from a radius and a center point.

Parameters:
  • center (Point) – The center of the polygon.
  • radius (float) – The distance from the center to the vertices of the polygon.
  • n (int) – The number of vertices of the regular polygon.
  • axis (Point, optional) – If constructed in higher-dimensional spaces, an axis vector is required to orient the polygon.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
center

The center of the polygon.

Type:Point
inradius

The inradius of the regular polygon.

Type:float
radius

The Circumradius of the regular polygon.

Type:float
class geometer.shapes.Segment(*args, **kwargs)[source]

Bases: geometer.shapes.Polytope

Represents a line segment in an arbitrary projective space.

Segments with one point at infinity represent rays/half-lines in a traditional sense.

Parameters:
  • *args – The start and endpoint of the line segment, either as two Point objects or a single coordinate array.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
contains(other, tol=1e-08)[source]

Tests whether a point is contained in the segment.

Parameters:
  • other (Point) – The point to test.
  • tol (float, optional) – The accepted tolerance.
Returns:

True if the point is contained in the segment.

Return type:

bool

intersect(other)[source]

Intersect the line segment with another object.

Parameters:other (Line, Plane, Segment, Polygon or Polyhedron) – The object to intersect the line segment with.
Returns:The points of intersection.
Return type:list of Point
length

The length of the segment.

Type:float
midpoint

The midpoint of the segment.

Type:Point
class geometer.shapes.SegmentCollection(*args, **kwargs)[source]

Bases: geometer.point.PointCollection

A collection of line segments.

Parameters:
  • *args – Two collections of points representing start and endpoints of the line segments or a (nested) sequence of coordinates for the start and endpoints.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
contains(other, tol=1e-08)[source]

Tests whether a point or a collection of points is contained in the line segments.

Parameters:
  • other (Point or PointCollection) – The points to test. If more than one point is given, the shape of the collection must be compatible with the shape of the segment collection.
  • tol (float, optional) – The accepted tolerance.
Returns:

Returns a boolean array of which points are contained in the line segments.

Return type:

numpy.ndarray

expand_dims(axis)[source]

Add a new index to the collection.

Parameters:axis (int) – Position in the new shape where the new axis is placed.
Returns:The tensor collection with an additional index.
Return type:TensorCollection
intersect(other)[source]

Intersect the line segments with a line, line segment or a collection of lines.

Parameters:other (Line, Segment, LineCollection or SegmentCollection) – The object to intersect the polygon with.
Returns:The points of intersection.
Return type:PointCollection
length

The lengths of the segments.

Type:array_like
midpoint

The midpoints of the segments.

Type:PointCollection
vertices

The start and endpoints of the line segments.

Type:list of PointCollection
class geometer.shapes.Simplex(*args, **kwargs)[source]

Bases: geometer.shapes.Polytope

Represents a simplex in any dimension, i.e. a k-polytope with k+1 vertices where k is the dimension.

The simplex determined by k+1 points is given by the convex hull of these points.

Parameters:
  • *args – The points that are the vertices of the simplex.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
volume

The volume of the simplex, calculated using the Cayley–Menger determinant.

Type:float
class geometer.shapes.Triangle(*args, **kwargs)[source]

Bases: geometer.shapes.Polygon, geometer.shapes.Simplex

A class representing triangles.

Parameters:
  • a (Point)
  • b (Point)
  • c (Point)
circumcenter

The circumcenter of the triangle.

Type:Point
contains(other)[source]

Tests whether a point is contained in the polygon.

Points on an edge of the polygon are considered True.

Parameters:other (Point or PointCollection) – The point to test.
Returns:True if the point is contained in the polygon.
Return type:array_like

References

[1]http://paulbourke.net/geometry/polygonmesh/#insidepoly

geometer.transformation module

class geometer.transformation.Transformation(*args, **kwargs)[source]

Bases: geometer.base.ProjectiveElement

Represents a projective transformation in an arbitrary projective space.

The underlying array is the matrix representation of the projective transformation. The matrix must be a nonsingular square matrix of size n+1 when n is the dimension of the projective space. The transformation can be applied to a point or another object by multiplication.

Parameters:
  • *args – The array that defines the matrix representing the transformation.
  • **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array.
apply(other)[source]

Apply the transformation to another object.

Parameters:other (Tensor) – The object to apply the transformation to.
Returns:The result of applying this transformation to the supplied object.
Return type:Tensor
classmethod from_points(*args)[source]

Constructs a projective transformation in n-dimensional projective space from the image of n + 2 points in general position.

For two dimensional transformations, 4 pairs of points are required, of which no three points are collinear. For three dimensional transformations, 5 pairs of points are required, of which no four points are coplanar.

Parameters:*args – Pairs of points, where in each pair one point is mapped to the other.
Returns:The transformation mapping each of the given points to the specified points.
Return type:Transformation

References

[1]
  1. Richter-Gebert: Perspectives on Projective Geometry, Proof of Theorem 3.4
classmethod from_points_and_conics(points1, points2, conic1, conic2)[source]

Constructs a projective transformation from two conics and the image of pairs of 3 points on the conics.

Parameters:
  • points1 (list of Point) – Source points on conic1.
  • points2 (list of Point) – Target points on conic2.
  • conic1 (Conic) – Source quadric.
  • conic2 (Conic) – Target quadric.
Returns:

The transformation that maps the points to each other and the conic to the other conic.

Return type:

Transformation

References

[1]https://math.stackexchange.com/questions/654275/homography-between-ellipses
inverse()[source]

Calculates the inverse projective transformation.

Returns:The inverse transformation.
Return type:Transformation
class geometer.transformation.TransformationCollection(*args, **kwargs)[source]

Bases: geometer.base.ProjectiveCollection

A Collection of transformations.

apply(other)[source]

Apply the transformations to another object.

Parameters:other (Tensor) – The object to apply the transformations to.
Returns:The result of applying the transformations to the supplied object.
Return type:TensorCollection
inverse()[source]

Calculates the inverse projective transformations.

Returns:The inverse transformations.
Return type:TransformationCollection
geometer.transformation.affine_transform(matrix=None, offset=0)[source]

Returns a projective transformation for the given affine transformation.

Parameters:
  • matrix (array_like, optional) – The transformation matrix.
  • offset (array_like or float, optional) – The translation.
Returns:

The projective transformation that represents the affine transformation.

Return type:

Transformation

geometer.transformation.identity(dim, collection_dims=None)[source]

Returns the identity transformation.

Parameters:
  • dim (int) – The dimension of the projective space that the transformation acts on.
  • collection_dims (tuple of int, optional) – Collection dimensions for a collection of identity transformations. By default only a single transformation is returned.
Returns:

The identity transformation(s).

Return type:

Transformation or TransformationCollection

geometer.transformation.reflection(axis)[source]

Returns a projective transformation that represents a reflection at the given axis/hyperplane.

Parameters:axis (Subspace) – The 2D-line or hyperplane to reflect points at.
Returns:The reflection.
Return type:Transformation

References

[1]https://en.wikipedia.org/wiki/Householder_transformation
geometer.transformation.rotation(angle, axis=None)[source]

Returns a projective transformation that represents a rotation by the specified angle (and axis).

Parameters:
  • angle (float) – The angle to rotate by.
  • axis (Point, optional) – The axis to rotate around when rotating points in 3D.
Returns:

The rotation.

Return type:

Transformation

References

[1]https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
geometer.transformation.scaling(*factors)[source]

Returns a projective transformation that represents general scaling by given factors in each dimension.

Parameters:*factors – The scaling factors by which each dimension is scaled.
Returns:The scaling transformation.
Return type:Transformation
geometer.transformation.translation(*coordinates)[source]

Returns a projective transformation that represents a translation by the given coordinates.

Parameters:*coordinates – The coordinates by which points are translated when applying the resulting transformation.
Returns:The translation.
Return type:Transformation