Math.Geometry


Builders

let outerPoints: Point2D<Meters, Cartesian> list =
    [ Point2D.meters 5. 0.
      Point2D.meters 7. 2.
      Point2D.meters 3. 6.
      Point2D.meters 2. 4.
      Point2D.meters 0. 2. ]

Polygon2D.singleLoop outerPoints
let innerPoints: Point2D<Meters, Cartesian> list =
    [ Point2D.meters 3. 1.; Point2D.meters 2. 2.; Point2D.meters 1. 1. ]

Polygon2D.withHoles [ innerPoints ] outerPoints
Polygon2D.convexHull

Accessors

let polygon: Polygon2D<Meters, Cartesian> =
    Polygon2D.withHoles [ innerPoints ] outerPoints

Polygon2D.outerLoop polygon // or
polygon.OuterLoop
No value returned by any evaluator
Polygon2D.innerLoops polygon // or
polygon.InnerLoops
No value returned by any evaluator
Polygon2D.vertices polygon
Polygon2D.loopEdges (Polygon2D.vertices polygon)
Polygon2D.edges polygon
Polygon2D.perimeter polygon
No value returned by any evaluator
Polygon2D.area polygon
No value returned by any evaluator
Polygon2D.centroid polygon
No value returned by any evaluator
Polygon2D.boundingBox polygon
No value returned by any evaluator

Modifiers

let invert = false
Polygon2D.mapVertices (Point2D.translate (Vector2D.meters 1. 2.)) invert polygon
Polygon2D.scaleAbout
Polygon2D.rotateAround
Polygon2D.translateBy
Polygon2D.translateIn
Polygon2D.mirrorAcross
Polygon2D.translate
Polygon2D.relativeTo
Polygon2D.boundingBox

Queries

Polygon2D.contains (Point2D.meters 2. 2.) polygon
No value returned by any evaluator
Polygon2D.contains (Point2D.meters 10. 10.) polygon
No value returned by any evaluator
namespace Math
namespace Math.Geometry
namespace Math.Units
Multiple items
union case Cartesian.Cartesian: Cartesian

--------------------
type Cartesian = | Cartesian
val outerPoints : Point2D<Meters,Cartesian> list
Multiple items
module Point2D from Math.Geometry

--------------------
[<Struct>] type Point2D<'Units,'Coordinates> = { X: Quantity<'Units> Y: Quantity<'Units> } interface IComparable interface IComparable<Point2D<'Units,'Coordinates>> interface IGeometry<'Coordinates> member Comparison : other:Point2D<'Units,'Coordinates> -> int override Equals : obj:obj -> bool + 1 overload override GetHashCode : unit -> int member LessThan : other:Point2D<'Units,'Coordinates> -> bool static member ( * ) : lhs:Point2D<'Units,'Coordinates> * rhs:float -> Point2D<'Units,'Coordinates> + 1 overload static member ( + ) : lhs:Point2D<'Units,'Coordinates> * rhs:Vector2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates> static member ( - ) : lhs:Point2D<'Units,'Coordinates> * rhs:Point2D<'Units,'Coordinates> -> Vector2D<'Units,'Coordinates> + 1 overload ...
Multiple items
union case Meters.Meters: Meters

--------------------
type Meters = | Meters
<category>Unit</category>
type 'T list = List<'T>
<summary>The type of immutable singly-linked lists. </summary>
<remarks>See the <see cref="T:Microsoft.FSharp.Collections.ListModule" /> module for further operations related to lists. Use the constructors <c>[]</c> and <c>::</c> (infix) to create values of this type, or the notation <c>[1; 2; 3]</c>. Use the values in the <c>List</c> module to manipulate values of this type, or pattern match against the values directly. See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/lists">F# Language Guide - Lists</a>. </remarks>
val meters : x:float -> y:float -> Point2D<Meters,'Coordinates>
Multiple items
module Polygon2D from Math.Geometry

--------------------
type Polygon2D<'Units,'Coordinates> = { OuterLoop: Point2D<'Units,'Coordinates> list InnerLoops: Point2D<'Units,'Coordinates> list list } interface IComparable interface IComparable<Polygon2D<'Units,'Coordinates>> interface IGeometry<'Coordinates> member Comparison : other:Polygon2D<'Units,'Coordinates> -> int override Equals : obj:obj -> bool + 1 overload override GetHashCode : unit -> int member LessThan : other:Polygon2D<'Units,'Coordinates> -> bool
val singleLoop : givenOuterLoop:Point2D<'a,'b> list -> Polygon2D<'a,'b>
<summary> Construct a polygon without holes from a list of its vertices: let rectangle = Polygon2D.singleLoop [ Point2D.meters 1. 1. Point2D.meters 3. 1. Point2D.meters 3. 2. Point2D.meters 1. 2. ] The last vertex is implicitly considered to be connected back to the first vertex (you do not have to close the polygon explicitly). Vertices should ideally be provided in counterclockwise order; if they are provided in clockwise order they will be reversed. </summary>
val innerPoints : Point2D<Meters,Cartesian> list
val withHoles : givenInnerLoops:Point2D<'Units,'Coordinates> list list -> givenOuterLoop:Point2D<'Units,'Coordinates> list -> Polygon2D<'Units,'Coordinates>
<summary> Construct a polygon with holes from one outer loop and a list of inner loops. The loops must not touch or intersect each other. let outerLoop = [ Point2D.meters 0. 0. Point2D.meters 3. 0. Point2D.meters 3. 3. Point2D.meters 0. 3. ] let innerLoop = [ Point2D.meters 1. 1. Point2D.meters 1. 2. Point2D.meters 2. 2. Point2D.meters 2. 1. ] let squareWithHole = Polygon2D.withHoles [ innerLoop ] outerLoop As with `Polygon2D.singleLoop`, the last vertex of each loop is considered to be connected back to the first. Vertices of the outer loop should ideally be provided in counterclockwise order and vertices of the inner loops should ideally be provided in clockwise order. </summary>
val convexHull : points:Point2D<'Units,'Coordinates> list -> Polygon2D<'Units,'Coordinates>
<summary> Build the [convex hull](https://en.wikipedia.org/wiki/Convex_hull) of a list of points. This is an O(n log n) operation. </summary>
val polygon : Polygon2D<Meters,Cartesian>
val outerLoop : polygon:Polygon2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates> list
<summary> Get the list of vertices defining the outer loop (border) of a polygon. The vertices will be in counterclockwise order. </summary>
Polygon2D.OuterLoop: Point2D<Meters,Cartesian> list
val innerLoops : polygon:Polygon2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates> list list
<summary> Get the holes (if any) of a polygon, each defined by a list of vertices. Each list of vertices will be in clockwise order. </summary>
Polygon2D.InnerLoops: Point2D<Meters,Cartesian> list list
val vertices : polygon:Polygon2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates> list
<summary> Get all vertices of a polygon; this will include vertices from the outer loop of the polygon and all inner loops. The order of the returned vertices is undefined. </summary>
val loopEdges : vertices_:Point2D<'Units,'Coordinates> list -> LineSegment2D<'Units,'Coordinates> list
val edges : polygon:Polygon2D<'Units,'Coordinates> -> LineSegment2D<'Units,'Coordinates> list
<summary> Get all edges of a polygon. This will include both outer edges and inner (hole) edges. </summary>
val perimeter : polygon:Polygon2D<'Units,'Coordinates> -> Quantity<'Units>
<summary> Get the perimeter of a polygon (the sum of the lengths of its edges). This includes the outer perimeter and the perimeter of any holes. </summary>
val area : polygon:Polygon2D<'Units,'Coordinates> -> Quantity<Squared<'Units>>
<summary> Get the area of a polygon. This value will never be negative. </summary>
val centroid : polygon:Polygon2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates> option
<summary> Get the centroid of a polygon. Returns `Nothing` if the polygon has no vertices or zero area. </summary>
val boundingBox : polygon:Polygon2D<'Units,'Coordinates> -> BoundingBox2D<'Units,'Coordinates> option
<summary> Get the minimal bounding box containing a given polygon. Returns `None` if the polygon has no vertices. </summary>
val invert : bool
val mapVertices : f:(Point2D<'UnitA,'CoordinatesA> -> Point2D<'UnitB,'CoordinatesB>) -> invert:bool -> polygon:Polygon2D<'UnitA,'CoordinatesA> -> Polygon2D<'UnitB,'CoordinatesB>
val translate : v:Vector2D<'Units,'Coordinates> -> p:Point2D<'Units,'Coordinates> -> Point2D<'Units,'Coordinates>
Multiple items
module Vector2D from Math.Geometry

--------------------
[<Struct>] type Vector2D<'Units,'Coordinates> = { X: Quantity<'Units> Y: Quantity<'Units> } interface IComparable interface IComparable<Vector2D<'Units,'Coordinates>> interface IGeometry<'Coordinates> member Comparison : other:Vector2D<'Units,'Coordinates> -> int override Equals : obj:obj -> bool + 1 overload override GetHashCode : unit -> int member LessThan : other:Vector2D<'Units,'Coordinates> -> bool static member ( * ) : vector:Vector2D<'Units,'Coordinates> * scale:float -> Vector2D<'Units,'Coordinates> + 1 overload static member ( + ) : lhs:Vector2D<'Units,'Coordinates> * rhs:Vector2D<'Units,'Coordinates> -> Vector2D<'Units,'Coordinates> static member ( - ) : lhs:Vector2D<'Units,'Coordinates> * rhs:Vector2D<'Units,'Coordinates> -> Vector2D<'Units,'Coordinates> ...
val meters : x:float -> y:float -> Vector2D<Meters,'Coordinates>
val scaleAbout : point:Point2D<'Units,'Coordinates> -> scale:float -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
<summary> Scale a polygon about a given center point by a given scale. If the given scale is negative, the order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order. </summary>
val rotateAround : point:Point2D<'Units,'Coordinates> -> angle:Angle -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
<summary> Rotate a polygon around the given center point counterclockwise by the given angle. </summary>
val translateBy : vector:Vector2D<'Units,'Coordinates> -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
<summary> Translate a polygon by the given displacement. </summary>
val translateIn : direction:Direction2D<'Coordinates> -> distance:Quantity<'Units> -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
<summary> Translate a polygon in a given direction by a given distance. </summary>
val mirrorAcross : axis:Axis2D<'Units,'Coordinates> -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
<summary> Mirror a polygon across the given axis. The order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order. </summary>
val translate : amount:Vector2D<'Units,'Coordinates> -> polygon:Polygon2D<'Units,'Coordinates> -> Polygon2D<'Units,'Coordinates>
val relativeTo : frame:Frame2D<'Units,'GlobalCoordinates,'LocalCoordinates> -> polygon:Polygon2D<'Units,'GlobalCoordinates> -> Polygon2D<'Units,'LocalCoordinates>
<summary> Take a polygon defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame. If the given frame is left-handed, the order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order. </summary>
val contains : point:Point2D<'Units,'Coordinates> -> polygon:Polygon2D<'Units,'Coordinates> -> bool
<summary> Check if a polygon contains a given point. This is an O(n) operation. The polygon can have holes and does not need to be convex. </summary>