Orasund/elm-hyperbolic/1.0.0

NOTE: the latest version is 1.1.0

Hyperbolic

Explore the hyperbolic space using this module. Checkout the doc for examples.

Points

type Point

Module for working with hyperbolic geometry. Uses the Beltrami–Klein model.

Ideal points have Beltrami coordinates with length 1.

Hyper ideal points have Beltrami coordinates with length > 1.

The origin is the point in the center.

An ideal point is a point at infinity, uniquely defined by an angle.

Returns if two point can be considered equal.

distanceTo : Point -> Point -> Float

Get the distance between two points

Distance to the origin

{ vertices : Int
, polygonsAroundAPoint : Int
}
-> Float

If you want to construct a tiling in the hyperbolic space, then the length of the polygon specifies how many polygons fit around a point.

If you look up tilings, you will usually find a Schläfli symbol {p,q}. In that case p = vertices, q = polygonsAroundAPoint.

The resulting length is for BeltramiCoords

Lines And Line Segments

type alias Line =

We define a line by two ideal points.

An ideal point is a point at infinity and can be represented by an angle

A hyper ideal point is a point that only exists in the euclidean projection of the hyperbolic plane into the Beltrami–Klein model.

type alias LineSegment =
( Point, Point )

A line segment is defined by two points

poleOfLine : Line -> Maybe HyperIdealPoint

Any line except lines going through the origin, can be associated by a unique hyper ideal point.

Constructs a line from two ideal points

lineFromIdealPoints : IdealPoint -> IdealPoint -> Line
lineFromIdealPoints =
    Tuple.pair
lineSectionTo : Point -> Point -> LineSegment

Constructs a line segment to a point

lineSectionTo : BeltramiPoint -> BeltramiPoint -> LineSegment
lineSectionTo =
    Tuple.pair
lineFromPoints : Point -> Point -> Maybe Line

constructs a line from two points

lineFromLineSegment : LineSegment -> Maybe Line

Convert a line segment into a line

Construct the midpoint of a line

midpointOfLineSegment : LineSegment -> Maybe Point

Get the midpoint of a line segment

Construct a line using an hyper ideal point

perpendicularLineThrough : Point -> Line -> Maybe Line

Point as to lie on the line

intersectLines : Line -> Line -> Maybe Point

Two lines may intersect at exactly one point

bisectorThrough : Point -> ( Point, Point ) -> Maybe Line

Construct a bisector through a point

reflectBy : Line -> Point -> Point

reflect a point by a line

Gyrovectors

Gyrovector in Poincare-Model

Creates a vector from two points. The length of the vector

Negate a vector

Using the Möbius Addition to add two vectors in the poincare disc

length : Gyrovector -> Float

Return the length of a vector

Addition for Gyrovectors in the Beltrami Disc Model.

Rotate the vector clockwise

Rotate a point clockwise around the origin

scale a vector by a factor

Convertion

pointsAlongLine : Int -> Line -> List Point

Constructs a given amount of point along a line

pointsAlongLineSegment : Int -> LineSegment -> List Point

Constructs a given amount of point along a line segment

{ radius : Float
, angle : Float
}
-> Point

Constructs a point using polar coordinates.

projectFromEuclideanSpace : ( Float, Float ) -> Point

Projects points from euclidean space into hyperbolic space. However, you can not expect the proportions to stay the same.

Points further out experience more distortion.

projectOntoBeltramiKleinDisc : Point -> ( Float, Float )

Project Hyperbolic points to the Beltrami klein disc

projectOntoPoincareDisc : Point -> ( Float, Float )

Project Hyperbolic points to the Poincare disc

Advanced

unsafeFromAxialCoord : ( Float, Float ) -> Point

Converts Beltrami Coordinates into Axial coordinates.

{ x : Float
, y : Float
}
-> Point
-> { x : Float
, y : Float
}
{ x : Float
, y : Float
}
-> { x : Float
, y : Float
}
unsafeToAxialCoord : Point -> Maybe ( Float, Float )

Converts Axial coordinates into Beltrami Coordinates.

-> { x : Float
, y : Float
}