﻿ Geometry

Geometry

1. Simple geometry entities together with simple calculations
2. Assumed are coordinates, where x points from left to right and Y points from bottom top
3. Implements only functionality needed in other libraries

Entities

Point

``` ```

``````  type Point =
class
new : x:float * y:float -> Point
member Copy : dx:float -> dy:float -> Point
member Equal : p:Point -> bool
member Rotate : center:Point -> angle:float -> Point
member X : float
member Y : float
static member Angle : p1:Point -> p2:Point -> float
static member Distance : p1:Point -> p2:Point -> float
end
``````
``` ```

Intersection

``` type IntersecType = | Overlap | Parallel | P of Point option ```

Intersection - straight line

If not parallel or overlapping, must exist

``` type PointIntersecExtend = class new : a:Point * b:Point * c:Point * d:Point -> PointIntersecExtend member Intersection : unit -> IntersecType end ```

Intersection - line

Intersection must lay on both lines a-b and c-d

``` type PointIntesecLimit = class new : a:Point * b:Point * c:Point * d:Point -> PointIntesecLimit member Intersection : unit -> IntersecType end ```

Line

``` ```

``````  type Line =
class
new : p1:Geometry.Point * p2:Geometry.Point -> Line
member Copy : dx:float -> dy:float -> Line
member IntersectWith : l:Line -> Geometry.IntersecType
member IntersectWithExtended : l:Line -> Geometry.IntersecType
member Rotate : center:Geometry.Point -> angle:float -> Line
member Angle : float
member Length : float
member P1 : Geometry.Point
member P2 : Geometry.Point
end
``````
``` ```

Polyline

Cannot intersect itself. Is meant for interpolations.

Minimal number of vertexes is 3

For intersection use methods in Line class

``` ```

``````  type Polyline =
class
new : points:Geometry.Point list -> Polyline
member Copy : dx:float -> dy:float -> Polyline
member Rotate : center:Geometry.Point -> angle:float -> Polyline
member Y : xi:float -> float
member Area : float
member Length : float
member Points : Geometry.Point list
end
``````
``` ```

Circle

No intersection supported. For intersection use methods in Line class

``` ```

``````  type Circle =
class
new : center:Geometry.Point * radius:float -> Circle
member Copy : dx:float -> dy:float -> Circle
member Rotate : center:Geometry.Point -> angle:float -> Circle
member Area : float
member Center : Geometry.Point
end
``````
``` ```

Polygon

Cannot crossing itself!

``` ```

``````  type Polygon =
class
new : points:Geometry.Point list -> Polygon
member Copy : dx:float -> dy:float -> Polygon
member Rotate : center:Geometry.Point -> angle:float -> Polygon
member Points : Geometry.Point list
static member CrossingItself : points:Geometry.Point list -> bool
end
``````
``` ```