package geoml

  1. Overview
  2. Docs
Geoml: 2D Geometry library for OCaml


Dune Dependency






Geoml is a 2D geometry for OCaml that provides basic euclidean geometry types (point, line, circle ...) and useful operations over those types. Computations are made using floatting point precision

Published: 24 Dec 2022



Geoml is 2D geometry library for OCaml. It focuses on euclidean geometry and provides basic types and operations over geometric shapes.

Here an example showing a way to construct geometrically a golden rectangle from four points defining a square:

  open Geoml
  let gold_rect (a,b,c,d) =
    let e = a b and ab = Line.of_points a b in
    let circ = Point.distance e c |> Circle.make e in
    let f =
      match Circle.line_intersection circ ab with
      | [x;y] -> if Point.sq_distance a x > Point.sq_distance a y then x else y
      | _ -> assert false
    let fg = Line.perpendicular_of_line ab f and dc = Line.of_points d c in
    let g = Line.intersection fg dc in
    Rectangle.make d (Point.distance d g) (Point.distance d a)

It also implements several cool algorithms :

  • Emo Welzl's smallest enclosing disk algorithm

  • Graham's scan method for finding a convex hull.

  • Weiler-Atherton for polygon clipping

  • Ear-clipping Algorithm for Polygon triangulation (Mei, Tipper & Xu)

You can see some examples of application in the tests directory (You'll need Graphics)

  • The library : make

  • The tests : make tests


You can build locally the documentation by doing make doc, or consult the online documentation.


Geoml is currently still in developpement, and have not been tested -nor proved, nor model-checked nor analyzed ... but you know what they say about well typed program ;) -. Thereby, you might find some weird behaviors or failures. Feel free to let us know or report an issue about it. The modules Point, Line, Rectangle, Vector, Triangle, Segment, Circle are pretty much usable while the Polygon, Polyhedron, Curve, Ellipse, Shape ... modules are not quite ready to be used and you should not rely on the code in it.

You are also welcome to contact any member of the developpement team if you want to report a bug or suggest a feature you think it may be cool to have in Geoml.

Dependencies (2)

  1. dune >= "2.4"
  2. ocaml >= "4.08.0"

Dev Dependencies (2)

  1. alcotest with-test
  2. odoc with-doc

Used by





Innovation. Community. Security.