All Projects → jan-mue → geometer

jan-mue / geometer

Licence: MIT license
A geometry library written in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to geometer

curve-shortening-demo
Visualize curve shortening flow in your browser.
Stars: ✭ 19 (-78.65%)
Mutual labels:  geometry, mathematics
Mather
zzllrr mather(an offline tool for Math learning, education and research)小乐数学,离线可用的数学学习(自学或教学)、研究辅助工具。计划覆盖数学全部学科的解题、作图、演示、探索工具箱。目前是演示Demo版(抛转引玉),但已经支持数学公式编辑显示,部分作图功能,部分学科,如线性代数、离散数学的部分解题功能。最终目标是推动专业数学家、编程专家、教育工作者、科普工作者共同打造出更加专业级的Mather数学工具
Stars: ✭ 270 (+203.37%)
Mutual labels:  geometry, mathematics
euclid.js
2D Euclidean geometry classes, utilities, and drawing tools
Stars: ✭ 69 (-22.47%)
Mutual labels:  geometry, mathematics
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (-68.54%)
Mutual labels:  geometry, mathematics
Korma
Mathematics library focused on geometry for Multiplatform Kotlin 1.3
Stars: ✭ 65 (-26.97%)
Mutual labels:  geometry, mathematics
alchemy
Generate any a-by-( b + c ) finite rectangle SVG containing potentially Infinitely many a-by-( 2 * b ) finite rectangles animated along a number line of ( ( c - b ) / a )^n scale symmetry.
Stars: ✭ 29 (-67.42%)
Mutual labels:  geometry, mathematics
spherical-cow
A high volume fraction sphere packing library
Stars: ✭ 24 (-73.03%)
Mutual labels:  geometry, mathematics
geometry
Geometric primitives for Ruby
Stars: ✭ 46 (-48.31%)
Mutual labels:  geometry, geometry-library
Jsxgraph
JSXGraph is a cross-browser library for interactive geometry, function plotting, charting, and data visualization in a web browser.
Stars: ✭ 605 (+579.78%)
Mutual labels:  geometry, mathematics
Cindyjs
A JavaScript framework for interactive (mathematical) content.
Stars: ✭ 495 (+456.18%)
Mutual labels:  geometry, mathematics
humke-4d-geometry
A web-based 4D Geometry viewer
Stars: ✭ 51 (-42.7%)
Mutual labels:  geometry, mathematics
Algorithms
A collection of algorithms and data structures
Stars: ✭ 11,553 (+12880.9%)
Mutual labels:  geometry, mathematics
birkhoff
Euclidean plane and its relatives; a minimalist introduction.
Stars: ✭ 15 (-83.15%)
Mutual labels:  geometry, mathematics
Dotscad
Reduce the burden of mathematics when playing OpenSCAD
Stars: ✭ 344 (+286.52%)
Mutual labels:  geometry, mathematics
Math Toolbox
Lightweight and modular math toolbox
Stars: ✭ 71 (-20.22%)
Mutual labels:  geometry, mathematics
Root
The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
Stars: ✭ 1,377 (+1447.19%)
Mutual labels:  geometry, mathematics
Cs231a Notes
The course notes for Stanford's CS231A course on computer vision
Stars: ✭ 230 (+158.43%)
Mutual labels:  geometry
reed-thesis
My undergradate thesis on coinductive types in univalent type theory
Stars: ✭ 14 (-84.27%)
Mutual labels:  mathematics
Geokit
Geo-Toolkit for PHP.
Stars: ✭ 223 (+150.56%)
Mutual labels:  geometry
Scikit Geometry
Scientific Python Geometric Algorithms Library
Stars: ✭ 220 (+147.19%)
Mutual labels:  geometry

geometer

image image image Build Status docs codecov

Geometer is a geometry 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.

Installation

You can install the package directly from PyPI:

pip install geometer

Usage

from geometer import *
import numpy as np

# Meet and Join operations
p = Point(2, 4)
q = Point(3, 5)
l = Line(p, q)
m = Line(0, 1, 0)
l.meet(m)
# Point(-2, 0)

# Parallel and perpendicular lines
m = l.parallel(through=Point(1, 1))
n = l.perpendicular(through=Point(1, 1))
is_perpendicular(m, n)
# True

# Angles and distances (euclidean)
a = angle(l, Point(1, 0))
p + 2*dist(p, q)*Point(np.cos(a), np.sin(a))
# Point(4, 6)

# Transformations
t1 = translation(0, -1)
t2 = rotation(-np.pi)
t1*t2*p
# Point(-2, -5)

# Collections of points and lines
coordinates = np.random.randint(100, size=(1000, 2))
points = PointCollection([Point(x, y) for x, y in coordinates])
lines = points.join(-points)
zero = PointCollection(np.zeros((1000, 2)), homogenize=True)
lines.meet(rotation(np.pi/2)*lines) == zero
# True

# Ellipses/Quadratic forms
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)
ellipse = Conic.from_foci(c, d, bound=b)

# Geometric shapes
o = Point(0, 0)
x, y = Point(1, 0), Point(0, 1)
r = Rectangle(o, x, x+y, y)
r.area
# 1

# 3-dimensional objects
p1 = Point(1, 1, 0)
p2 = Point(2, 1, 0)
p3 = Point(3, 4, 0)
l = p1.join(p2)
A = join(l, p3)
A.project(Point(3, 4, 5))
# Point(3, 4, 0)

l = Line(Point(1, 2, 3), Point(3, 4, 5))
A.meet(l)
# Point(-2, -1, 0)

p3 = Point(1, 2, 0)
p4 = Point(1, 1, 1)
c = Cuboid(p1, p2, p3, p4)
c.area
# 6

# Cross ratios
t = rotation(np.pi/16)
crossratio(q, t*q, t**2 * q, t**3 * q, p)
# 1.4408954235712448

# Higher dimensions
p1 = Point(1, 1, 4, 0)
p2 = Point(2, 1, 5, 0)
p3 = Point(3, 4, 6, 0)
p4 = Point(0, 2, 7, 0)
E = Plane(p1, p2, p3, p4)
l = Line(Point(0, 0, 0, 0), Point(1, 2, 3, 4))
E.meet(l)
# Point(0, 0, 0, 0)

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].