Skip to content

HMath.Geometry

Module index · Numerical conventions

Description

Checked Cartesian geometry and bounded CPU reference algorithms. Coordinates are finite with absolute value <=1e50; ND dimensions are 1..16. Raw primitive constructors are convenient for pattern matching, so every checked operation revalidates its inputs. Boundaries are included unless an API returns an explicit Location. Two-dimensional positive orientation is counterclockwise; three-dimensional coordinates are right-handed.

Polygon Boolean output rings preserve hole orientation. Constrained Delaunay constraints are noncrossing edges, not a polygon-domain/hole specification. Spatial queries expose exact/budget-exhaustion status. Collision support APIs operate on planar convex hulls; camera transforms follow OpenGL depth rules. Each algorithm documents its finite reference budget in the defining module.

On this page

API Purpose
Point2 Cartesian two-dimensional point, also used for vectors.
P2 Declaration and type contract below.
Point3 Cartesian right-handed three-dimensional point/vector.
P3 Declaration and type contract below.
PointND A point of dimension 1..16.
PointND Declaration and type contract below.
point2 Given x,y, construct Point2 after bounded finite-coordinate validation.
point3 Given x,y,z, construct Point3 after bounded finite-coordinate validation.
pointND Construct a checked ND point from 1..16 bounded finite coordinates.
Line Parametric line origin+t*direction; direction must be nonzero.
Line Declaration and type contract below.
Ray Parametric ray origin+t*direction, t>=0.
Ray Declaration and type contract below.
Segment Closed segment with two endpoints; zero length is valid.
Segment Declaration and type contract below.
Plane Plane normal dot x = offset, with a nonzero normal.
Plane Declaration and type contract below.
Triangle Closed triangle; zero-area triangles are rejected by triangle operations.
Triangle Declaration and type contract below.
Rectangle Axis-aligned rectangle with ordered corners.
Rectangle Declaration and type contract below.
Circle Circle with nonnegative radius.
Circle Declaration and type contract below.
Ellipse Rotated ellipse: positive semiaxes, counterclockwise angle in radians.
Ellipse Declaration and type contract below.
Polygon Simple polygon; vertices are implicitly closed and no duplicate endpoint is needed.
Polygon Declaration and type contract below.
Sphere Closed sphere, including a zero radius.
Sphere Declaration and type contract below.
AABB Ordered, closed axis-aligned bounds in 1..16 dimensions.
AABB Declaration and type contract below.
OBB Oriented three-dimensional box: center, three orthonormal axes, half-extents.
OBB Declaration and type contract below.
Capsule Capsule around the closed axis segment.
Capsule Declaration and type contract below.
Cylinder Finite cylinder with endpoint centers and radius; endpoints must differ.
Cylinder Declaration and type contract below.
Cone Finite cone with apex, base center, and radius; axis must be nonzero.
Cone Declaration and type contract below.
Frustum Convex frustum represented by six inward half-spaces n dot x >= offset.
Frustum Declaration and type contract below.
Orientation Sign of an exact predicate on the input Double values.
Clockwise Declaration and type contract below.
Collinear Declaration and type contract below.
Counterclockwise Declaration and type contract below.
Location Point position with boundary reported separately.
Outside Declaration and type contract below.
Boundary Declaration and type contract below.
Inside Declaration and type contract below.

Documentation

Point2

data Point2 Source #

Cartesian two-dimensional point, also used for vectors.

Constructors

P2 Double Double 

Instances

Instances details
Show Point2 Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Point2 Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Point2 -> Point2 -> Bool #

(/=) :: Point2 -> Point2 -> Bool #

Ord Point2 Source # 
Instance details

Defined in HMath.Geometry.Internal

Point3

data Point3 Source #

Cartesian right-handed three-dimensional point/vector.

Constructors

P3 Double Double Double 

Instances

Instances details
Show Point3 Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Point3 Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Point3 -> Point3 -> Bool #

(/=) :: Point3 -> Point3 -> Bool #

Ord Point3 Source # 
Instance details

Defined in HMath.Geometry.Internal

PointND

newtype PointND Source #

A point of dimension 1..16.

Constructors

PointND [Double] 

Instances

Instances details
Show PointND Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq PointND Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: PointND -> PointND -> Bool #

(/=) :: PointND -> PointND -> Bool #

Ord PointND Source # 
Instance details

Defined in HMath.Geometry.Internal

point2

point2 :: Double -> Double -> Either MathError Point2 Source #

Given x,y, construct Point2 after bounded finite-coordinate validation. Invalid values return DomainError.

point3

point3 :: Double -> Double -> Double -> Either MathError Point3 Source #

Given x,y,z, construct Point3 after bounded finite-coordinate validation. Invalid values return DomainError.

pointND

pointND :: [Double] -> Either MathError PointND Source #

Construct a checked ND point from 1..16 bounded finite coordinates. Invalid dimension/value returns DomainError.

Line

data Line Source #

Parametric line origin+t*direction; direction must be nonzero.

Constructors

Line PointND PointND 

Instances

Instances details
Show Line Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> Line -> ShowS #

show :: Line -> String #

showList :: [Line] -> ShowS #

Eq Line Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Line -> Line -> Bool #

(/=) :: Line -> Line -> Bool #

Ray

data Ray Source #

Parametric ray origin+t*direction, t>=0.

Constructors

Ray Point3 Point3 

Instances

Instances details
Show Ray Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> Ray -> ShowS #

show :: Ray -> String #

showList :: [Ray] -> ShowS #

Eq Ray Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Ray -> Ray -> Bool #

(/=) :: Ray -> Ray -> Bool #

Segment

data Segment Source #

Closed segment with two endpoints; zero length is valid.

Constructors

Segment PointND PointND 

Instances

Instances details
Show Segment Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Segment Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Segment -> Segment -> Bool #

(/=) :: Segment -> Segment -> Bool #

Plane

data Plane Source #

Plane normal dot x = offset, with a nonzero normal.

Constructors

Plane Point3 Double 

Instances

Instances details
Show Plane Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> Plane -> ShowS #

show :: Plane -> String #

showList :: [Plane] -> ShowS #

Eq Plane Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Plane -> Plane -> Bool #

(/=) :: Plane -> Plane -> Bool #

Triangle

data Triangle Source #

Closed triangle; zero-area triangles are rejected by triangle operations.

Instances

Instances details
Show Triangle Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Triangle Source # 
Instance details

Defined in HMath.Geometry.Internal

Rectangle

data Rectangle Source #

Axis-aligned rectangle with ordered corners.

Constructors

Rectangle Point2 Point2 

Instances

Instances details
Show Rectangle Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Rectangle Source # 
Instance details

Defined in HMath.Geometry.Internal

Circle

data Circle Source #

Circle with nonnegative radius.

Constructors

Circle Point2 Double 

Instances

Instances details
Show Circle Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Circle Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Circle -> Circle -> Bool #

(/=) :: Circle -> Circle -> Bool #

Ellipse

data Ellipse Source #

Rotated ellipse: positive semiaxes, counterclockwise angle in radians.

Instances

Instances details
Show Ellipse Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Ellipse Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Ellipse -> Ellipse -> Bool #

(/=) :: Ellipse -> Ellipse -> Bool #

Polygon

newtype Polygon Source #

Simple polygon; vertices are implicitly closed and no duplicate endpoint is needed.

Constructors

Polygon [Point2] 

Instances

Instances details
Show Polygon Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Polygon Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Polygon -> Polygon -> Bool #

(/=) :: Polygon -> Polygon -> Bool #

Sphere

data Sphere Source #

Closed sphere, including a zero radius.

Constructors

Sphere Point3 Double 

Instances

Instances details
Show Sphere Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Sphere Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Sphere -> Sphere -> Bool #

(/=) :: Sphere -> Sphere -> Bool #

AABB

data AABB Source #

Ordered, closed axis-aligned bounds in 1..16 dimensions.

Constructors

AABB PointND PointND 

Instances

Instances details
Show AABB Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> AABB -> ShowS #

show :: AABB -> String #

showList :: [AABB] -> ShowS #

Eq AABB Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: AABB -> AABB -> Bool #

(/=) :: AABB -> AABB -> Bool #

OBB

data OBB Source #

Oriented three-dimensional box: center, three orthonormal axes, half-extents.

Constructors

OBB Point3 [Point3] Point3 

Instances

Instances details
Show OBB Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> OBB -> ShowS #

show :: OBB -> String #

showList :: [OBB] -> ShowS #

Eq OBB Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: OBB -> OBB -> Bool #

(/=) :: OBB -> OBB -> Bool #

Capsule

data Capsule Source #

Capsule around the closed axis segment.

Constructors

Capsule Point3 Point3 Double 

Instances

Instances details
Show Capsule Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Capsule Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Capsule -> Capsule -> Bool #

(/=) :: Capsule -> Capsule -> Bool #

Cylinder

data Cylinder Source #

Finite cylinder with endpoint centers and radius; endpoints must differ.

Instances

Instances details
Show Cylinder Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Cylinder Source # 
Instance details

Defined in HMath.Geometry.Internal

Cone

data Cone Source #

Finite cone with apex, base center, and radius; axis must be nonzero.

Constructors

Cone Point3 Point3 Double 

Instances

Instances details
Show Cone Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

showsPrec :: Int -> Cone -> ShowS #

show :: Cone -> String #

showList :: [Cone] -> ShowS #

Eq Cone Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Cone -> Cone -> Bool #

(/=) :: Cone -> Cone -> Bool #

Frustum

newtype Frustum Source #

Convex frustum represented by six inward half-spaces n dot x >= offset.

Constructors

Frustum [Plane] 

Instances

Instances details
Show Frustum Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Frustum Source # 
Instance details

Defined in HMath.Geometry.Internal

Methods

(==) :: Frustum -> Frustum -> Bool #

(/=) :: Frustum -> Frustum -> Bool #

Orientation

data Orientation Source #

Sign of an exact predicate on the input Double values.

Location

data Location Source #

Point position with boundary reported separately.

Constructors

Outside 
Boundary 
Inside 

Instances

Instances details
Show Location Source # 
Instance details

Defined in HMath.Geometry.Internal

Eq Location Source # 
Instance details

Defined in HMath.Geometry.Internal

Ord Location Source # 
Instance details

Defined in HMath.Geometry.Internal