geometer Documentation Release 0.2.3

Jan Müller

Sep 27, 2021

Contents:

1 Installation 3 1.1 Quickstart...... 3 1.2 API Reference...... 5 1.3 Changelog...... 36

2 Indices and tables 41 2.1 References...... 41

Python Module Index 43

Index 45

i ii geometer Documentation, Release 0.2.3

Geometer is a library for Python that uses projective geometry and numpy for fast geometric computation. In projective geometry every point in 2D is represented by a three-dimensional vector and every point in 3D is represented by a four-dimensional vector. This has the following advantages: • There are points at infinity that can be treated just like normal points. • Projective transformations are described by matrices but they can also represent translations and general affine transformations. • Two lines have a unique point of intersection if they lie in the same plane. Parallel lines have a point of intersection at infinity. • Points of intersection, planes or lines through given points can be calculated using simple cross products or tensor diagrams. • Special complex points at infinity and cross ratios can be used to calculate angles and to construct perpendicular geometric structures. • Collections of points and lines can be represented by tensors. Their connecting lines and intersections can be calculated using fast matrix multiplications. Most of the computation in the library is done via tensor diagrams (using numpy.einsum). The source code of the package can be found on GitHub and the documentation on Read the Docs.

Contents: 1 geometer Documentation, Release 0.2.3

2 Contents: CHAPTER 1

Installation

You can install the package directly from PyPI: pip install geometer

1.1 Quickstart

1.1.1 Geometry in Two Dimensions

The elementary objects of projective geometry, points and lines can be created using the Point and classes without having to specify the dimension: from geometer import * p= Point(2,4) q= Point(3,5) l= Line(p, q) m= Line(0,1,0)

Here we specified a line once by two base points and once using the of the line. The two elementary operations meet and join can also be called called exactly as one would expect: l= join(p, q) r= meet(l, m)

Geometer can also construct parallel and perpendicular lines: m=l.parallel(through=Point(1,1)) n=l.perpendicular(through=Point(1,1)) is_perpendicular(m, n)

The function is_perpendicular() returns True when two lines are perpendicular. Other angles an distances can also be calculated:

3 geometer Documentation, Release 0.2.3

a= angle(l, Point(1,0)) dist(l, p) import numpy as np p+2 *dist(p, q)*Point(np.cos(a), np.sin(a))

Projective transformations can be easily created using the methods rotation and translation or by supplying a matrix to the Transformation class: t1= translation(0,-1) t2= rotation(-np.pi) t3= Transformation([[0,1,0], [1,0,0], [0,0,1]]) t1*t2*p

Geometer also includes tools to work with conics. They can be created using the classes Conic or Circle: a= Point(-1,0) b= Point(0,3) c= Point(1,2) d= Point(2,1) e= Point(0,-1) conic= Conic.from_points(a, b, c, d, e)

To calculate cross ratios of points or lines, the function crossratio() can be used: t= rotation(np.pi/16) crossratio(q, t*q, t**2 * q, t**3 * q, p)

Other interesting operators are harmonic_set(), angle_bisectors(), is_cocircular() and is_collinear().

1.1.2 Geometry in Three Dimensions

Creating points and lines in 3D works the same as in the two dimensional case: p1= Point(1,1,0) p2= Point(2,1,0) p3= Point(3,4,0) l= Line(p1, p2)

In addition to points and lines, in three dimensions we can use the Plane class or the join operation to create planes:

A= join(l, p3) A.project(Point(3,4,5))

Points can be projected onto planes and lines. The result is still a point in 3D but now lying on the plane. The point of intersection of a plane and a line can be calculated with the meet operation: l= Line(Point(1,2,3), Point(3,4,5)) A.meet(l)

All other operations such as angles, distances, perpendicular lines, cross ratios are also compatible with objects in 3D. For information on their usage, you can look at the two dimensional example.

4 Chapter 1. Installation geometer Documentation, Release 0.2.3

1.2 API Reference

1.2.1 geometer package geometer.utils package geometer.utils.math.adjugate(A) Calculates the adjugate matrix of A. The resulting matrix is defined by

푖+푗 adj(퐴)푖푗 = (−1) 푀푗푖,

where 푀푗푖 is the determinant of the submatrix of 퐴 obtained by deleting the j-th row and the i-th column of 퐴. For small matrices, this function uses the following formula (Einstein notation): 1 adj(퐴) = 휀 휀 퐴 . . . 퐴 푖푗 (푛 − 1)! 푖 푖2...푖푛 푗 푗2...푗푛 푗2푖2 푗푛푖푛

Source (German): https://de.wikipedia.org/wiki/Levi-Civita-Symbol#Zusammenhang_mit_der_Determinante ParametersA ((. . . , M, M) array_like) – The input matrix. Returns The adjugate of A. Return type (.., M, M) numpy.ndarray geometer.utils.math.det(A) Computes the determinant of A. ParametersA ((. . . , M, M) array_like) – The input matrix. Returns The determinant of A. Return type (..) array_like geometer.utils.math.hat_matrix(*args) Builds a skew symmetric matrix with the given scalars in the positions shown below.

⎛ 0 푐 −푏⎞ ⎝−푐 0 푎 ⎠ 푏 −푎 0

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) Computes the inverse of A. ParametersA ((. . . , 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-15, atol=1e-08) Returns a boolean array where two arrays are scalar multiples of each other along a given axis.

1.2. API Reference 5 geometer Documentation, Release 0.2.3

This function compares the absolute value of the scalar product and the product of the norm of the arrays (along an axis). The Cauchy-Schwarz inequality guarantees in its edge case that this equality holds if and only if one of the vectors is a scalar multiple of the other. 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, ad- joint_b=False, **kwargs) 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) 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) Constructs an orthonormal basis for the null space of a A using SVD. Parameters • A ((. . . , M, N) array_like) – The input matrix.

6 Chapter 1. Installation geometer Documentation, Release 0.2.3

• 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) 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) Calculates the roots of a polynomial for the given coefficients. The polynomial is defined as

푝[0]푥푛 + 푝[1]푥푛−1 + ... + 푝[푛 − 1]푥 + 푝[푛].

Parametersp (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) 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: ⎧ +1 if (휈 , . . . , 휈 ) are an even permutation of (휇 , . . . , 휇 ) ⎨⎪ 1 푝 1 푝 훿휇1...휇푝 = 휈1...휈푝 −1 if (휈1, . . . , 휈푝) are an odd permutation of (휇1, . . . , 휇푝) ⎩⎪0 else

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 class geometer.base.LeviCivitaTensor(size, covariant=True) Bases: geometer.base.Tensor This class can be used to construct a tensor representing the Levi-Civita symbol.

1.2. API Reference 7 geometer Documentation, Release 0.2.3

The Levi-Civita symbol is also called 휀-Tensor and is defined as follows: ⎧ +1 if (휈 , . . . , 휈 ) are an even permutation of (1, . . . , 푛) ⎨⎪ 1 푛 휀휈1...휈푛 = −1 if (휈1, . . . , 휈푛) are an odd permutation of (1, . . . , 푛) ⎩⎪0 else 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

class geometer.base.ProjectiveCollection(elements, *, covariant=True, tensor_rank=1, **kwargs) 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) 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) 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

8 Chapter 1. Installation geometer Documentation, Release 0.2.3

References

T The transposed tensor, same as self.transpose(). copy() dtype The dtype of the underlying numpy array, same as self.array.dtype. Type numpy.dtype is_zero(tol=1e-08) 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) 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) Permute the indices of the tensor. Parameters perm (tuple of int, optional) – A list of permuted indices or a shorter list represent- ing 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) Bases: geometer.base.Tensor A collection of Tensor objects with identical covariant/contravariant indices and shape stored in a tensor. Parameters

1.2. API Reference 9 geometer Documentation, Release 0.2.3

• 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 con- tained 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 collec- tion 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) 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) 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 퐴푖푗퐵푙 , where 푗, 푘, 푙 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

add_edge(source, target) 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) Add a node to the tensor diagram without adding an edge/contraction.

10 Chapter 1. Installation geometer Documentation, Release 0.2.3

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() Calculates the result of the diagram. Returns The tensor resulting from the specified tensor diagram. Return type Tensor copy() geometer.curve module class geometer.curve.Circle(center=Point(0.0, 0.0), radius=1, **kwargs) 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) 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

lie_coordinates The Lie coordinates of the circle as point in RP4. Type Point radius The radius of the circle. Type float

1.2. API Reference 11 geometer Documentation, Release 0.2.3

class geometer.curve.Cone(vertex=Point(0.0, 0.0, 0.0), base_center=Point(0.0, 0.0, 1.0), radius=1, **kwargs) 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) 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) 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

classmethod from_foci(f1, f2, bound) 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) Construct a degenerate conic from two lines. Parameters g, h (Line) – The two lines the conic consists of. Returns The resulting conic.

12 Chapter 1. Installation geometer Documentation, Release 0.2.3

Return type Conic classmethod from_points(a, b, c, d, e) 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(, a, b, c, d) 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) 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

polar(pt) 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) 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.0, 0.0), direction=Point(0.0, 0.0, 1.0), ra- dius=1, **kwargs) 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.

1.2. API Reference 13 geometer Documentation, Release 0.2.3

• **kwargs – Additional keyword arguments for the constructor of the numpy array as defined in numpy.array. class geometer.curve.Ellipse(center=Point(0.0, 0.0), hradius=1, vradius=1, **kwargs) 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) 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 푛 + 1 where 푛 is the dimension of the . If 퐴 ∈ R(푛+1)×(푛+1), the quadric contains all points 푥 ∈ R푛+1 such that 푥푇 퐴푥 = 0. Parameters • matrix (array_like or Tensor) – A two-dimensional array defining the (n+1)x(n+1) sym- metric 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) 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.

14 Chapter 1. Installation geometer Documentation, Release 0.2.3

Type Quadric classmethod from_planes(e, f ) 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) 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

is_degenerate True if the quadric is degenerate. Type bool is_tangent(plane) 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) 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) 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) 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.

1.2. API Reference 15 geometer Documentation, Release 0.2.3

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) 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) 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) 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.0, 0.0), radius=1, **kwargs) 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.

16 Chapter 1. Installation geometer Documentation, Release 0.2.3

Type float volume The volume of the sphere. Type float

geometer.exceptions module

exception geometer.exceptions.GeometryException Bases: Exception A general geometric error occurred. exception geometer.exceptions.IncidenceError Bases: geometer.exceptions.GeometryException, ValueError The given objects were not incident to each other. exception geometer.exceptions.LinearDependenceError(message, depen- dent_values=True) Bases: geometer.exceptions.GeometryException, ValueError The given values were linearly dependent, making the computation impossible. exception geometer.exceptions.NotCollinear Bases: geometer.exceptions.GeometryException, ValueError The given values are not collinear. exception geometer.exceptions.NotCoplanar Bases: geometer.exceptions.GeometryException, ValueError The given values are not coplanar. exception geometer.exceptions.NotReducible Bases: geometer.exceptions.GeometryException, ValueError The given geometric object is not reducible. exception geometer.exceptions.TensorComputationError Bases: geometer.exceptions.GeometryException An error during a tensor computation occurred. geometer.operators module geometer.operators.angle(*args) 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 −휋푖 and 휋푖) and multiplies it with 1/2푖, this function can only calculate angles between −휋/2 and 휋/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.

1.2. API Reference 17 geometer Documentation, Release 0.2.3

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 geometer.operators.angle_bisectors(l, m) 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) 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) Calculates the (euclidean) distance between two objects. Instead of the usual formula for the euclidean distance this function uses the following formula that is projec- tively invariant (in P and Q): ⃒ ⃒ ⃒√︀[푃, 푄, 퐼][푃, 푄, 퐽]⃒ ⃒ ⃒ dist(푃, 푄) = 4 ⃒ ⃒ ⃒ [푃, 퐼, 퐽][푄, 퐼, 퐽] ⃒

Parameters p, q (Point, Line, Plane or Polygon) – The points, lines or planes to calculate the dis- tance between. Returns The distance between the given objects. Return type array_like

References geometer.operators.harmonic_set(a, b, c) 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.

18 Chapter 1. Installation geometer Documentation, Release 0.2.3

Return type Point or PointCollection geometer.operators.is_cocircular(a, b, c, d, rtol=1e-15, atol=1e-08) 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) 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) 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) 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) Tests whether two lines/planes are perpendicular. Parameters

1.2. API Reference 19 geometer Documentation, Release 0.2.3

• 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) 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) 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

20 Chapter 1. Installation geometer Documentation, Release 0.2.3

References

lie_coordinates The Lie coordinates of a line in 2D. Type Point mirror(pt) 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

perpendicular(through, plane=None) Construct the perpendicular line though a point. Parameters • through (Point, PointCollection) – The point through which the perpendicular is con- structed. • 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) 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) 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

1.2. API Reference 21 geometer Documentation, Release 0.2.3

covariant_tensor The covariant tensors of lines in 3D. Type LineCollection direction The direction of the lines (not normalized). Type PointCollection mirror(pt) Construct the reflection of points at the lines. Parameters pt (Point, PointCollection) – The point to reflect. Returns The mirror points. Return type PointCollection

References

perpendicular(through, plane=None) Construct the perpendicular line though a point. Parameters • through (Point, PointCollection) – The point through which the perpendicular is con- structed. • 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) 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) 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

22 Chapter 1. Installation geometer Documentation, Release 0.2.3

mirror(pt) 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) 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) 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) 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) 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) 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.

1.2. API Reference 23 geometer Documentation, Release 0.2.3

Returns The perpendicular lines or planes. Return type LineCollection or PlaneCollection project(pt) 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) 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 coor- dinates 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 join(*others) 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) Bases: geometer.base.ProjectiveCollection A collection of points. Parameters

24 Chapter 1. Installation geometer Documentation, Release 0.2.3

• 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 homo- geneous 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 join(*others) normalized_array The coordinate array of the points with the last coordinates normalized to 1. Type numpy.ndarray class geometer.point.Subspace(*args, **kwargs) 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) 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) 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) Execute the join of the subspace with other objects.

1.2. API Reference 25 geometer Documentation, Release 0.2.3

Parameters *others – The objects to join the subspace with. Returns The result of the join operation. Return type Subspace See also: join() meet(*others) 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) 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 con- structed. Returns The parallel subspace. Return type Subspace class geometer.point.SubspaceCollection(elements, *, tensor_rank=1, **kwargs) 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) 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

26 Chapter 1. Installation geometer Documentation, Release 0.2.3

join(*others) meet(other) parallel(through) 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 sub- spaces are to be constructed. Returns The parallel subspaces. Return type SubspaceCollection geometer.point.infty_hyperplane(dimension) geometer.point.join(*args, _check_dependence=True, _normalize_result=True) 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) 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) 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) 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.

1.2. API Reference 27 geometer Documentation, Release 0.2.3

• **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) 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

edges The edges of the polygon. Type SegmentCollection facets The facets of the polytope. Type list of Polytope intersect(other) 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) 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) se- quence of vertex coordinates.

28 Chapter 1. Installation geometer Documentation, Release 0.2.3

• **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) 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 See also: Polygon.contains() edges The edges of the polygons in the collection. Type SegmentCollection expand_dims(axis) 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) Intersect the polygons with a line, line segment or a collection of lines. Parameters other (Line, Segment, LineCollection or SegmentCollection) – The object to inter- sect the polygon with. Returns The points of intersection. Return type PointCollection See also: Polygon.intersect() vertices The vertices of the polygons. Type list of PointCollection class geometer.shapes.Polyhedron(*args, **kwargs) 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.

1.2. API Reference 29 geometer Documentation, Release 0.2.3

Type list of Segment faces The faces of the polyhedron. Type PolygonCollection intersect(other) 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) 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) 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) Bases: geometer.shapes.Polygon A class that can be used to construct regular polygon from a radius and a center point.

30 Chapter 1. Installation geometer Documentation, Release 0.2.3

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 re- quired 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) 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) 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) 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

1.2. API Reference 31 geometer Documentation, Release 0.2.3

length The length of the segment. Type float midpoint The midpoint of the segment. Type Point class geometer.shapes.SegmentCollection(*args, **kwargs) 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) 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 See also: Segment.contains() expand_dims(axis) 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) Intersect the line segments with a line, line segment or a collection of lines. Parameters other (Line, Segment, LineCollection or SegmentCollection) – The object to inter- sect the polygon with. Returns The points of intersection. Return type PointCollection See also: Segment.intersect() length The lengths of the segments. Type array_like

32 Chapter 1. Installation geometer Documentation, Release 0.2.3

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) 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) 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) 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

geometer.transformation module

class geometer.transformation.Transformation(*args, **kwargs) Bases: geometer.base.ProjectiveElement Represents a projective transformation in an arbitrary projective space.

1.2. API Reference 33 geometer Documentation, Release 0.2.3

The underlying array is the matrix representation of the projective transformation. The matrix must be a non- singular 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) 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) 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

classmethod from_points_and_conics(points1, points2, conic1, conic2) 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

inverse() Calculates the inverse projective transformation. Returns The inverse transformation. Return type Transformation

34 Chapter 1. Installation geometer Documentation, Release 0.2.3 class geometer.transformation.TransformationCollection(*args, **kwargs) Bases: geometer.base.ProjectiveCollection A Collection of transformations. apply(other) 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() Calculates the inverse projective transformations. Returns The inverse transformations. Return type TransformationCollection geometer.transformation.affine_transform(matrix=None, offset=0) 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) 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) 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 geometer.transformation.rotation(angle, axis=None) 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.

1.2. API Reference 35 geometer Documentation, Release 0.2.3

Returns The rotation. Return type Transformation

References geometer.transformation.scaling(*factors) 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) Returns a projective transformation that represents a translation by the given coordinates. Parameters *coordinates – The coordinates by which points are translated when applying the re- sulting transformation. Returns The translation. Return type Transformation

1.3 Changelog

1.3.1 0.3 - unreleased

1.3.2 New Features

• Removed sympy as dependency • Added TensorCollection class and the following subclasses: – ProjectiveCollection – SubspaceCollection – PointCollection – LineCollection – PlaneCollection – TransformationCollection – SegmentCollection – PolygonCollection – QuadricCollection • Faster intersection of lines with polygons & polyhedra by using the new collections • All functions in the operators module support collections in addition to the existing types • Support for TensorCollection objects in tensor diagrams • Implemented intersection of quadrics with a collection of lines • Support for Tensor indexing

36 Chapter 1. Installation geometer Documentation, Release 0.2.3

• Added Tensor.is_zero() • Added construction of a perpendicular plane through a line on another plane • Reformatted source code with black • Added Transformation.from_points_and_conics to map two conics and pairs of three points • Added Triangle.circumcenter

1.3.3 Bug fixes

• Fixed a bug in the calculation of points of intersection of two conics (issue #36)

1.3.4 0.2.3 - released (8.7.2020)

1.3.5 New Features

• Added Tensor.dtype property • Added parameters to Tensor class to control ndarray creation (e.g. for setting the dtype) • Quadrics can now be normalized using their (pseudo-) determinant to reduce numerical errors • The underlying arrays of tensors are copied less often (controlled by copy parameter) • Implemented addition/subtraction of points to a quadric • Transformations can be applied to any object of type Tensor • More robust algorithm for calculating the intersection of conics • Added a determinant function that is faster for matrices in dimension 2 and 3 • Updated dependencies (up to NumPy 1.19 and SymPy 1.6 now supported)

1.3.6 Bug fixes

• Fixed error that was raised when integer arrays are normalized in the join/meet function • Fixed issues caused by an array not being converted to a Point object in Line.base_point and Line.directions • Correct handling of special cases in the calculation of the crossing number in Polygon.contains • Trying to raise an arbitrary tensor to power zero now correctly raises an NotImplementedError • Equality of polytopes is determined correctly even if the vertices are in a different order

1.3.7 0.2.2 - released (15.2.2020)

1.3.8 New Features

• New adjugate function in utils.math • New algorithms for Segment.contains, Conic.intersect & Conic.from_crossratio

1.3. Changelog 37 geometer Documentation, Release 0.2.3

1.3.9 Bug fixes

• Fixed an issue with numerical stability when intersecting transformed polytopes (issue #24) • Conic.components uses a better algorithm that should give correct results in all cases • Quadric.intersect no longer throws a ValueError when a 3D line has only a single point of intersection • Line.base_point will now try to always return finite points and Line.direction a point at infinity • Arrays with small component values are handled correctly by the is_multiple function • Fixed an issue with Polygon.contains that caused the direction used in the method to be close to zero (issue #25) • Transformation of line in 3D now works correctly • The functions null_space and orth now use the same threshold values as Matlab for truncating the singular values

1.3.10 0.2.1 - released (3.2.2020)

1.3.11 New Features

• Added properties shape, rank and T to Tensor class • Tensor instances can be raised to an arbitrary positive power • Dynamic calculation of center and radius attributes of RegularPolygon instances • Added RegularPolygon.inradius property • Polytope is now a subclass of Tensor • Added functions for generating transforms that perform scaling and reflections • Added Polygon.centroid property • Updated numpy to version 1.18

1.3.12 Bug fixes

• Transformations are now applied correctly to quadrics and conics • Fixed bug that made transformation of Cuboid & RegularPolygon fail (issue #23) • Raising transformations to a power (other than 1) is calculated correctly • Tolerance parameters are correctly used in Tensor.__eq__ • Scalar multiplication with Points is calculated correctly using normalized_array • Fixed copy method Tensor subclasses • Return real angles instead of angles with complex type • Fixed init method of regular polygons that aren’t centered at the origin • Indices passed to Tensor constructor are validated and negative indices converted • Fixed init method of Cone & Cylinder classes

38 Chapter 1. Installation geometer Documentation, Release 0.2.3

1.3.13 Deprecations

• Deprecated AlgebraicCurve, Subspace.polygons, Plane.polygon, Quadric.polygon and the module utils.polynomial in preparation of removal of sympy as dependency

1.3.14 0.2 - released (15.9.2019)

1.3.15 New Features

• New shapes module that implements line segments, polygons and general polytopes • New Sphere class (a subclass of Quadric) that works in any dimension • New classes representing a cone and a cylinder in 3D • Tensor has a new tensor_product method to calculate the tensor product with another tensor • Ellipse class that constructs a conic from center and radius • Added Conic.foci and Conic.polar • Construct a conic from its focal points, using a tangent line or a cross ratio • Faster and more general intersect method for quadrics • Refactored & documented the code for calculation of tensor diagrams • New KroneckerDelta tensor • TensorDiagram calculates results differently, using free indices from front to back • New method TensorDiagram.add_node to add tensors without edge to the diagram • Added Circle.intersection_angle to calculate the angle of intersection of two circles • is_perpendicular now works with two planes • New function is_multiple in utils module

1.3.16 Bug fixes

• Plane.perpendicular now also works for points that lie on the plane • Addition/Subtraction of subspaces and points works in more cases • Adding a point at infinity to another point will give a finite point moved in that direction • Globally accessible tolerance parameters to avoid inaccurate calculations (issue #22) • Fixed Transformation.from_points

1.3.17 0.1.2 - released (24.2.2019)

1.3.18 New Features

• Optimized performance of Conic, LeviCivitaTensor and TensorDiagram • More operations are now compatible with higher-dimensional objects • New Subspace class that can be used to represent subspaces of any dimension

1.3. Changelog 39 geometer Documentation, Release 0.2.3

• New repr and copy methods of Tensor • scipy is no longer a dependency

1.3.19 Bug fixes

• Rotation in 3D now returns the correct transformation if the axis is not a normalized vector • Line.perpendicular now also works for points tha lie on the line

1.3.20 0.1.1 - released (2.2.2019)

40 Chapter 1. Installation CHAPTER 2

Indices and tables

• genindex • modindex • search

2.1 References

Many of the algorithms and formulas implemented in the package are taken from the following books and papers: • Jürgen Richter-Gebert, Perspectives on Projective Geometry • Jürgen Richter-Gebert and Thorsten Orendt, Geometriekalküle • Olivier Faugeras, Three-Dimensional Computer Vision • Jim Blinn, Lines in Space: The 4D Cross Product • Jim Blinn, Lines in Space: The Line Formulation • Jim Blinn, Lines in Space: The Two Matrices • Jim Blinn, Lines in Space: Back to the Diagrams • Jim Blinn, Lines in Space: A Tale of Two Lines • Jim Blinn, Lines in Space: Our Friend the Hyperbolic Paraboloid • Jim Blinn, Lines in Space: The Algebra of Tinkertoys • Jim Blinn, Lines in Space: Line(s) through Four Lines

41 geometer Documentation, Release 0.2.3

42 Chapter 2. Indices and tables Python Module Index

g geometer.base,7 geometer.curve, 11 geometer.exceptions, 17 geometer.operators, 17 geometer.point, 20 geometer.shapes, 27 geometer.transformation, 33 geometer.utils.math,5

43 geometer Documentation, Release 0.2.3

44 Python Module Index Index

A method), 11 add_edge() (geometer.base.TensorDiagram method), center (geometer.curve.Circle attribute), 11 10 center (geometer.curve.Sphere attribute), 16 add_node() (geometer.base.TensorDiagram method), center (geometer.shapes.RegularPolygon attribute), 31 10 centroid (geometer.shapes.Polygon attribute), 28 adjugate() (in module geometer.utils.math),5 Circle (class in geometer.curve), 11 affine_transform() (in module geome- circumcenter (geometer.shapes.Triangle attribute), ter.transformation), 35 33 angle() (in module geometer.operators), 17 components (geometer.curve.Quadric attribute), 14 angle_bisectors() (in module geome- components (geometer.curve.QuadricCollection at- ter.operators), 18 tribute), 15 angles (geometer.shapes.Polygon attribute), 28 Cone (class in geometer.curve), 11 apply() (geometer.transformation.Transformation Conic (class in geometer.curve), 12 method), 34 contains() (geometer.curve.Quadric method), 14 apply() (geometer.transformation.TransformationCollectioncontains() (geometer.curve.QuadricCollection method), 35 method), 15 area (geometer.curve.Circle attribute), 11 contains() (geometer.point.Subspace method), 25 area (geometer.curve.Sphere attribute), 16 contains() (geometer.point.SubspaceCollection area (geometer.shapes.Polygon attribute), 28 method), 26 area (geometer.shapes.PolygonCollection attribute), 29 contains() (geometer.shapes.Polygon method), 28 area (geometer.shapes.Polyhedron attribute), 29 contains() (geometer.shapes.PolygonCollection array (geometer.base.Tensor attribute),8 method), 29 array (geometer.shapes.Polytope attribute), 30 contains() (geometer.shapes.Segment method), 31 contains() (geometer.shapes.SegmentCollection B method), 32 contains() (geometer.shapes.Triangle method), 33 base_point (geometer.point.Line attribute), 20 contravariant_tensor (geometer.point.Line at- base_point (geometer.point.LineCollection attribute), tribute), 20 21 contravariant_tensor (geome- basis_matrix (geometer.point.Line attribute), 20 ter.point.LineCollection attribute), 21 basis_matrix (geometer.point.Plane attribute), 22 copy() (geometer.base.Tensor method),9 basis_matrix (geometer.point.PlaneCollection at- copy() (geometer.base.TensorDiagram method), 11 tribute), 23 covariant_tensor (geometer.point.Line attribute), basis_matrix (geometer.point.Subspace attribute), 20 25 covariant_tensor (geometer.point.LineCollection basis_matrix (geometer.point.SubspaceCollection attribute), 21 attribute), 26 crossratio() (in module geometer.operators), 18 C Cuboid (class in geometer.shapes), 27 Cylinder (class in geometer.curve), 13 calculate() (geometer.base.TensorDiagram

45 geometer Documentation, Release 0.2.3

D geometer.base (module),7 det() (in module geometer.utils.math),5 geometer.curve (module), 11 dim (geometer.base.ProjectiveCollection attribute),8 geometer.exceptions (module), 17 dim (geometer.base.ProjectiveElement attribute),8 geometer.operators (module), 17 direction (geometer.point.Line attribute), 20 geometer.point (module), 20 direction (geometer.point.LineCollection attribute), geometer.shapes (module), 27 22 geometer.transformation (module), 33 dist() (in module geometer.operators), 18 geometer.utils.math (module),5 dtype (geometer.base.Tensor attribute),9 GeometryException, 17 dual (geometer.curve.Quadric attribute), 14 dual (geometer.curve.QuadricCollection attribute), 16 H harmonic_set() (in module geometer.operators), 18 E hat_matrix() (in module geometer.utils.math),5 edges (geometer.shapes.Polygon attribute), 28 edges (geometer.shapes.PolygonCollection attribute), I 29 identity() (in module geometer.transformation), 35 edges (geometer.shapes.Polyhedron attribute), 29 IncidenceError, 17 Ellipse (class in geometer.curve), 14 infty_hyperplane() (in module geometer.point), expand_dims() (geometer.base.TensorCollection 27 method), 10 inradius (geometer.shapes.RegularPolygon attribute), expand_dims() (geometer.shapes.PolygonCollection 31 method), 29 intersect() (geometer.curve.Conic method), 13 expand_dims() (geometer.shapes.SegmentCollection intersect() (geometer.curve.Quadric method), 15 method), 32 intersect() (geometer.curve.QuadricCollection method), 16 F intersect() (geometer.shapes.Polygon method), 28 faces (geometer.shapes.Polyhedron attribute), 30 intersect() (geometer.shapes.PolygonCollection facets (geometer.shapes.Polygon attribute), 28 method), 29 facets (geometer.shapes.Polytope attribute), 30 intersect() (geometer.shapes.Polyhedron method), flat (geometer.base.TensorCollection attribute), 10 30 foci (geometer.curve.Conic attribute), 12 intersect() (geometer.shapes.Segment method), 31 from_crossratio() (geometer.curve.Conic class intersect() (geometer.shapes.SegmentCollection method), 12 method), 32 from_foci() (geometer.curve.Conic class method), 12 intersection_angle() (geometer.curve.Circle from_lines() (geometer.curve.Conic class method), method), 11 12 inv() (in module geometer.utils.math),5 from_planes() (geometer.curve.Quadric class inverse() (geometer.transformation.Transformation method), 15 method), 34 from_points() (geometer.curve.Conic class method), inverse() (geometer.transformation.TransformationCollection 13 method), 35 from_points() (geome- is_cocircular() (in module geometer.operators), ter.transformation.Transformation class 19 method), 34 is_collinear() (in module geometer.operators), 19 from_points_and_conics() (geome- is_concurrent() (in module geometer.operators), ter.transformation.Transformation class 19 method), 34 is_coplanar() (geometer.point.Line method), 20 from_tangent() (geometer.curve.Conic class is_coplanar() (in module geometer.operators), 19 method), 13 is_degenerate (geometer.curve.Quadric attribute), 15 G is_degenerate (geometer.curve.QuadricCollection general_point (geometer.point.Subspace attribute), attribute), 16 25 is_dual (geometer.curve.Quadric attribute), 14 general_point (geometer.point.SubspaceCollection is_multiple() (in module geometer.utils.math),5 attribute), 26

46 Index geometer Documentation, Release 0.2.3 is_parallel() (geometer.point.Subspace method), normalized_array (geometer.point.PointCollection 25 attribute), 25 is_perpendicular() (in module geome- NotCollinear, 17 ter.operators), 19 NotCoplanar, 17 is_tangent() (geometer.curve.Quadric method), 15 NotReducible, 17 is_tangent() (geometer.curve.QuadricCollection null_space() (in module geometer.utils.math),6 method), 16 is_zero() (geometer.base.Tensor method),9 O isinf (geometer.point.Point attribute), 24 orth() (in module geometer.utils.math),7 isinf (geometer.point.PointCollection attribute), 25 P J parallel() (geometer.point.Subspace method), 26 join() (geometer.point.Point method), 24 parallel() (geometer.point.SubspaceCollection join() (geometer.point.PointCollection method), 25 method), 27 join() (geometer.point.Subspace method), 25 perpendicular() (geometer.point.Line method), 21 join() (geometer.point.SubspaceCollection method), perpendicular() (geometer.point.LineCollection 26 method), 22 join() (in module geometer.point), 27 perpendicular() (geometer.point.Plane method), 23 perpendicular() (geometer.point.PlaneCollection K method), 23 KroneckerDelta (class in geometer.base),7 Plane (class in geometer.point), 22 PlaneCollection (class in geometer.point), 23 L Point (class in geometer.point), 24 length (geometer.shapes.Segment attribute), 31 PointCollection (class in geometer.point), 24 length (geometer.shapes.SegmentCollection attribute), polar() (geometer.curve.Conic method), 13 32 Polygon (class in geometer.shapes), 27 LeviCivitaTensor (class in geometer.base),7 PolygonCollection (class in geometer.shapes), 28 lie_coordinates (geometer.curve.Circle attribute), Polyhedron (class in geometer.shapes), 29 11 Polytope (class in geometer.shapes), 30 lie_coordinates (geometer.point.Line attribute), 21 project() (geometer.point.Line method), 21 lie_coordinates (geometer.point.Point attribute), project() (geometer.point.LineCollection method), 22 24 project() (geometer.point.Plane method), 23 Line (class in geometer.point), 20 project() (geometer.point.PlaneCollection method), LinearDependenceError, 17 24 LineCollection (class in geometer.point), 21 ProjectiveCollection (class in geometer.base),8 ProjectiveElement M (class in geometer.base),8 matmul() (in module geometer.utils.math),6 Q matvec() (in module geometer.utils.math),6 Quadric (class in geometer.curve), 14 meet() (geometer.point.Subspace method), 26 QuadricCollection (class in geometer.curve), 15 meet() (geometer.point.SubspaceCollection method), 27 R meet() (in module geometer.point), 27 radius (geometer.curve.Circle attribute), 11 midpoint (geometer.shapes.Segment attribute), 32 radius (geometer.curve.Sphere attribute), 16 midpoint (geometer.shapes.SegmentCollection at- radius (geometer.shapes.RegularPolygon attribute), 31 tribute), 32 rank (geometer.base.Tensor attribute),9 mirror() (geometer.point.Line method), 21 Rectangle (class in geometer.shapes), 30 mirror() (geometer.point.LineCollection method), 22 reflection() (in module geometer.transformation), mirror() (geometer.point.Plane method), 22 35 mirror() (geometer.point.PlaneCollection method), 23 RegularPolygon (class in geometer.shapes), 30 N roots() (in module geometer.utils.math),7 rotation() (in module geometer.transformation), 35 normalized_array (geometer.point.Point attribute), 24

Index 47 geometer Documentation, Release 0.2.3

S scaling() (in module geometer.transformation), 36 Segment (class in geometer.shapes), 31 SegmentCollection (class in geometer.shapes), 32 shape (geometer.base.Tensor attribute),9 Simplex (class in geometer.shapes), 33 size (geometer.base.TensorCollection attribute), 10 Sphere (class in geometer.curve), 16 Subspace (class in geometer.point), 25 SubspaceCollection (class in geometer.point), 26 T T (geometer.base.Tensor attribute),9 tangent() (geometer.curve.Conic method), 13 tangent() (geometer.curve.Quadric method), 15 tangent() (geometer.curve.QuadricCollection method), 16 Tensor (class in geometer.base),8 tensor_product() (geometer.base.Tensor method), 9 tensor_shape (geometer.base.Tensor attribute),9 TensorCollection (class in geometer.base),9 TensorComputationError, 17 TensorDiagram (class in geometer.base), 10 Transformation (class in geometer.transformation), 33 TransformationCollection (class in geome- ter.transformation), 34 translation() (in module geometer.transformation), 36 transpose() (geometer.base.Tensor method),9 Triangle (class in geometer.shapes), 33 V vertices (geometer.shapes.Polygon attribute), 28 vertices (geometer.shapes.PolygonCollection at- tribute), 29 vertices (geometer.shapes.Polytope attribute), 30 vertices (geometer.shapes.SegmentCollection at- tribute), 33 volume (geometer.curve.Sphere attribute), 17 volume (geometer.shapes.Simplex attribute), 33

48 Index