# / Computational Geometry Primitives

`The package provides some basic geometric types in the cg submodule.`

## Package Features

- Provides types: Point, Segment, Line, Polygon.

## Basic geometric types

`FrechetDist.cg.Line`

— Type```
Line in D dimensions.
`p` is a point on the line and `u` is the direction vector (not
necessarily normalized). Parametrised as $p + ut$
```

`FrechetDist.cg.Point`

— Type```
Point
Point in D dimensions. Implemented currently as a struct with
StaticArray for values. It is templated, with `N` for dimension,
and `T` for underlying type.
```

`FrechetDist.cg.Segment`

— Type`Segment`

Specifies a *directed* segment by two endpoints.

## Functions

`FrechetDist.cg.Polygon_read_plt_orig_file`

— Function```
Polygon_read_plt_orig_file
Reads a .plt file into a polygon (2d floating point).
```

`FrechetDist.cg.Polygon_split_edges`

— Method`Polygon_split_edges`

Output a polygon, where each edge is split in the middle by introducing a vertex into it.

`FrechetDist.cg.Polygon_write_to_file`

— Method```
Polygon_write_to_file
Writes a plt file of the polygon.
```

`FrechetDist.cg.Segment_get_bisection_point`

— Method```
Segment_get_bisection_point -> Bool, Real, Point
Computes the intersection point of the segment `seg` with the
```

bisector plane between `p`

and `q`

.

**Returns**

The first argument returns whether the segment intersects the bisector, the pramaterized location (tm), and the intersection piont itself.

`FrechetDist.cg.Segment_nn_point`

— Method`Segment_nn_point`

Returns the closest point on the segment `s`

to the query point `qr`

.

`FrechetDist.cg.dist_seg_nn_point`

— Method`dist_seg_nn_point`

Returns the *distance* to the closest point lying on the segment induced by the first two points, to the query point. By avoiding creating the segment iself, it is hopeflly more efficient.

`FrechetDist.cg.induced_seg_nn_point`

— Method`induced_seg_nn_point`

Returns the closest point to the segment induced by the first two points, to the query point. By avoiding creating the segment iself, it is hopeflly more efficient.

`FrechetDist.cg.point`

— Method`point( args... )`

A flexible constructor for a point specified by the arguments. Thus point( 2.0, 3.0, 4.0 ) defined the 3d point (2.0, 3.0, 4.0). Or similarly, point( 2.0, 1.0 ) would create a 2d point.

`FrechetDist.cg.segs_match_price`

— Method`segs_match_price`

The price of matching the edge p*a-p*b to the edge q*a-q*b.