PoincareDisk
Drawing primitives in the hyperbolic Poincare Disk Model with Cairo
Install / Use
/learn @dcoeurjo/PoincareDiskREADME
PoincareDisk
authors: David Coeurjolly, Derek Moore
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
- C/C++ compiler
- cmake http://www.cmake.org
- Cairo/libcairo http://cairographics.org
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).

Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
