• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

geometer/H08-Jul-2020-3,8842,909

geometer.egg-info/H03-May-2022-158130

LICENSEH A D09-Dec-20191 KiB2217

MANIFEST.inH A D22-Dec-201926 21

PKG-INFOH A D08-Jul-20205.9 KiB158130

README.mdH A D18-Apr-20204.3 KiB140113

setup.cfgH A D08-Jul-202038 53

setup.pyH A D03-May-20223.4 KiB12781

README.md

1# geometer
2
3[![image](https://img.shields.io/pypi/v/geometer.svg)](https://pypi.org/project/geometer/)
4[![image](https://img.shields.io/pypi/l/geometer.svg)](https://pypi.org/project/geometer/)
5[![image](https://img.shields.io/pypi/pyversions/geometer.svg)](https://pypi.org/project/geometer/)
6[![Build Status](https://travis-ci.org/jan-mue/geometer.svg?branch=master)](https://travis-ci.org/jan-mue/geometer)
7[![codecov](https://codecov.io/github/jan-mue/geometer/coverage.svg?branch=master)](https://codecov.io/github/jan-mue/geometer)
8[![Downloads](https://pepy.tech/badge/geometer)](https://pepy.tech/project/geometer)
9
10Geometer is a geometry library for Python 3 that uses projective geometry and numpy for fast geometric computation.
11In projective geometry every point in 2D is represented by a three-dimensional vector and every point in 3D
12is represented by a four-dimensional vector. This has the following advantages:
13
14- There are points at infinity that can be treated just like normal points.
15- Projective transformations are described by matrices but they can also
16  represent affine transformations i.e. also translations.
17- Every two lines have a unique point of intersection if they lie in the same
18  plane. Parallel lines have a point of intersection at infinity.
19- Points of intersection, planes or lines through given points can be
20  calculated using simple cross products or tensor diagrams.
21- Special complex points at infinity and cross ratios can be used to calculate
22  angles and to construct perpendicular geometric structures.
23
24Most of the computation in the library is done via tensor diagrams (using numpy.einsum).
25
26Geometer was originally built as a learning exercise and is based on two graduate courses taught at the
27Technical University Munich. After investing a lot of time in the project, it is now reasonably well tested
28and the API should be stable.
29
30The source code of the package can be found on [GitHub](https://github.com/jan-mue/geometer)
31and the documentation on [Read the Docs](https://geometer.readthedocs.io).
32
33## Installation
34
35You can install the package directly from PyPI:
36```bash
37pip install geometer
38```
39
40## Usage
41
42```Python
43from geometer import *
44import numpy as np
45
46# Meet and Join operations
47p = Point(2, 4)
48q = Point(3, 5)
49l = Line(p, q)
50m = Line(0, 1, 0)
51l.meet(m)
52# Point(-2, 0)
53
54# Parallel and perpendicular lines
55m = l.parallel(through=Point(1, 1))
56n = l.perpendicular(through=Point(1, 1))
57is_perpendicular(m, n)
58# True
59
60# Angles and distances (euclidean)
61a = angle(l, Point(1, 0))
62p + 2*dist(p, q)*Point(np.cos(a), np.sin(a))
63# Point(4, 6)
64
65# Transformations
66t1 = translation(0, -1)
67t2 = rotation(-np.pi)
68t1*t2*p
69# Point(-2, -5)
70
71# Ellipses/Quadratic forms
72a = Point(-1, 0)
73b = Point(0, 3)
74c = Point(1, 2)
75d = Point(2, 1)
76e = Point(0, -1)
77
78conic = Conic.from_points(a, b, c, d, e)
79ellipse = Conic.from_foci(c, d, bound=b)
80
81# Geometric shapes
82o = Point(0, 0)
83x, y = Point(1, 0), Point(0, 1)
84r = Rectangle(o, x, x+y, y)
85r.area
86# 1
87
88# 3-dimensional objects
89p1 = Point(1, 1, 0)
90p2 = Point(2, 1, 0)
91p3 = Point(3, 4, 0)
92l = p1.join(p2)
93A = join(l, p3)
94A.project(Point(3, 4, 5))
95# Point(3, 4, 0)
96
97l = Line(Point(1, 2, 3), Point(3, 4, 5))
98A.meet(l)
99# Point(-2, -1, 0)
100
101p3 = Point(1, 2, 0)
102p4 = Point(1, 1, 1)
103c = Cuboid(p1, p2, p3, p4)
104c.area
105# 6
106
107# Cross ratios
108t = rotation(np.pi/16)
109crossratio(q, t*q, t**2 * q, t**3 * q, p)
110# 1.4408954235712448
111
112# Higher dimensions
113p1 = Point(1, 1, 4, 0)
114p2 = Point(2, 1, 5, 0)
115p3 = Point(3, 4, 6, 0)
116p4 = Point(0, 2, 7, 0)
117E = Plane(p1, p2, p3, p4)
118l = Line(Point(0, 0, 0, 0), Point(1, 2, 3, 4))
119E.meet(l)
120# Point(0, 0, 0, 0)
121
122```
123
124## References
125
126Many of the algorithms and formulas implemented in the package are taken from
127the following books and papers:
128
129- Jürgen Richter-Gebert, Perspectives on Projective Geometry
130- Jürgen Richter-Gebert and Thorsten Orendt, Geometriekalküle
131- Olivier Faugeras, Three-Dimensional Computer Vision
132- Jim Blinn, Lines in Space: The 4D Cross Product
133- Jim Blinn, Lines in Space: The Line Formulation
134- Jim Blinn, Lines in Space: The Two Matrices
135- Jim Blinn, Lines in Space: Back to the Diagrams
136- Jim Blinn, Lines in Space: A Tale of Two Lines
137- Jim Blinn, Lines in Space: Our Friend the Hyperbolic Paraboloid
138- Jim Blinn, Lines in Space: The Algebra of Tinkertoys
139- Jim Blinn, Lines in Space: Line(s) through Four Lines
140