Git Product home page Git Product logo

poincaredisk's Introduction

PoincareDisk

authors: David Coeurjolly

The Poincaré disk model is one of the n-d hyperbolic geometry models.

In dimension 2, the disc is defined for points x in the unit disc equiped with an hyperbolic metric. In this model, straight lines are circular arcs orthogonal to the unit disc boundary. Hence, the shortest path between two points is uniquely defined from the circular arc orthogonal to the boundary containing the two points. Since triangles are hyperbolic triangles, sum of internal angles of a triangle is always less or equal to pi.

This project implements basic drawing functions to display straight lines, straight segment and hyperbolic triangle in this model. In order to keep the code as simple as possible, it consists of a unique C++ header file with quite self explanatory functions. The PDF export is done by the Cairo library.

Requirements

Examples

The syntax is very simple, for example, to draw an hyperbolic segment where vertices are given in polar coordinates:

initPDF("poincare-edge.pdf");
drawUnitCircle();
drawEdge(Point(0.5,0.5), Point(-0.6,0.2),true);
flushPDF();

Note that drawing methods are based on a template parameter “Point” which implements points in dimension 2. Here you have a very simple model to construct points on “double” type.

struct Point{
 Point(double xx, double yy): myX(xx),myY(yy)
 {}
 double x() const
 {return myX;}
 double y() const
 {return myY;}
 double myX,myY;
};

In the header file, several hyperbolic objects can be displayed: points

  • hyperbolic lines
  • hyperbolic segment (with or without support line)
  • hyperbolic triangles

You can customize colors (method parameters) and width of objects (global variables). Here you have couple of generated figures: Poincaré disc and an hyperbolic segment, hyperbolic triangles (regular one and an ideal one), and hyperbolic uniformization of a polyhedron (a torus with two holes, only one period is displayed).

poincaredisk's People

Contributors

dcoeurjo avatar derekm avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

superobserver

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.