Geometer Documentation Release 0.2.3

Geometer Documentation Release 0.2.3

geometer Documentation Release 0.2.3 Jan Müller Jul 08, 2020 Contents: 1 Installation 3 1.1 Quickstart................................................3 1.2 API Reference..............................................5 1.3 Changelog................................................ 30 2 Indices and tables 33 2.1 References................................................ 33 Python Module Index 35 Index 37 i ii geometer Documentation, Release 0.2.3 Geometer is a geometry library for Python 3 that uses projective geometry and numpy for fast geometric computa- tion. 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 affine transformations i.e. also translations. • Every 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. Most of the computation in the library 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 Line 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 homogeneous coordinates 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 i+j adj(A)ij = (−1) Mji; where Mji 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): 1 adj(A) = " " A :::A ij (n − 1)! i i2:::in j j2:::jn j2i2 jnin 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 c −b1 @−c 0 a A b −a 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.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. 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. 1.2. API Reference 5 geometer Documentation, Release 0.2.3 • 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.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. • 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.polynomial.np_array_to_poly(c, symbols) Converts an array of coefficients into a sympy polynomial. Deprecated since version 0.2.1: np_array_to_poly will be removed in geometer 0.3. If c an array of shape (m; : : : ; m) and variables x1; : : : ; xn are given as symbols, the resulting polynomial will be given by X i1 in c[i1; : : : ; in]x1 ··· xn : 0≤i1;:::;in≤m−1 Parameters • c (array_like) – Array of coefficients where the different axis correspond to different vari- ables with the degree in each axis given by the corresponding index. • symbols (list of sympy.Symbol) – The symbols to be used as variables of the polynomial. Returns The resulting polynomial as described above. Return type sympy.Poly geometer.utils.polynomial.poly_to_np_array(p, symbols) Convert a sympy polynomial to an array of coefficients as required by numpy. Deprecated since version 0.2.1: poly_to_np_array will be removed in geometer 0.3. 6 Chapter 1. Installation geometer Documentation, Release 0.2.3 If p is a multivariate polynomial with the variables x1; : : : ; xn specified in symbols, the resulting array will be such that X i1 in p = c[i1; : : : ; in]x1 ··· xn : 0≤i1;:::;in≤m−1 Parameters • p (sympy.Expr) – The sympy expression that represents the polynomial. • symbols (list of sympy.Symbol) – The variables used in the polynomial expression. Returns The coefficients of the polynomial as described above. Return type numpy.ndarray geometer.utils.polynomial.polyval(x, c) Evaluate a multivariate polynomial at a specified point. Deprecated since version 0.2.1: polyval will be removed in geometer 0.3. If x is an array of length n and c an array of shape (m; : : : ; m), the result is X i1 in c[i1; : : : ; in]x[1] ··· x[n] : 0≤i1;:::;in≤m−1 Parameters • x (array_like) – The point to evaluate the polynomial at. • c (array_like) – Array of coefficients where the different axis correspond to different vari- ables with the degree in each axis given by the corresponding index. Returns The result of the evaluation as described above. Return type float or complex 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.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us