# Module Mlpost.Point

`module Point: `sig` .. `end``
Points in the plane

`type t = `Signature.point` `
The abstract type for points
`val pt : `Num.t * Num.t -> t``
Construct a point from two numeric values

The following functions create points of length 1. They are especially useful to specify directions with `Path.Vec`
`val dir : `float -> t``
`dir f` is the point at angle `f` on the unit circle. `f` shall be given in degrees

The unitary vectors pointing up, down, left and right
`val up : `t``
`val down : `t``
`val left : `t``
`val right : `t``
`val origin : `t``
`val length : `t -> Num.t``
`length p` is the length of vector from the origin to `p`
`val xpart : `t -> Num.t``
`xpart p` is the x coordinate of point `p`
`val ypart : `t -> Num.t``
`ypart p` is the y coordinate of point `p`

## Operations on points

`val transform : `Transform.t -> t -> t``
Apply a transformation to a point
`val segment : `float -> t -> t -> t``
`segment f p1 p2` is the point `(1-f)p1 + fp2`. Stated otherwise, if `p1` is at `0.` and `p2` is at `1.`, return the point that lies at `f`
`val add : `t -> t -> t``
`val shift : `t -> t -> t``
Sum two points
`val sub : `t -> t -> t``
Substract two points
`val mult : `Num.t -> t -> t``
`val scale : `Num.t -> t -> t``
Multiply a point by a scalar
`val rotate : `float -> t -> t``
Rotate a point by an angle in degrees
`val rotate_around : `t -> float -> t -> t``
`rotate_around p1 f p2` rotates `p2` around `p1` by an angle `f` in degrees
`val xscale : `Num.t -> t -> t``
Scales the X coordinate of a point by a scalar
`val yscale : `Num.t -> t -> t``
Scales the Y coordinate of a point by a scalar
`val normalize : `t -> t``
Normalize the vector represented by the point. The origin becomes the origin

## Convenient constructors

The following functions build a point at a given scale (see `Num.t` for scales)
`val bpp : `float * float -> t``
`val inp : `float * float -> t``
`val cmp : `float * float -> t``
`val mmp : `float * float -> t``
`val ptp : `float * float -> t``

Same as the previous functions but build list of points
`val map_bp : `(float * float) list -> t list``
`val map_in : `(float * float) list -> t list``
`val map_cm : `(float * float) list -> t list``
`val map_mm : `(float * float) list -> t list``
`val map_pt : `(float * float) list -> t list``
`val p : `?scale:(float -> Num.t) -> float * float -> t``
Builds a point from a pair of floats
`scale` : a scaling function to be applied to each float; see `Num.t` for scaling functions for usual units
`val ptlist : `?scale:(float -> Num.t) -> (float * float) list -> t list``
Same as `p`, but builds a list of points
`val draw : `?brush:Brush.t ->       ?color:Color.t ->       ?pen:Pen.t -> t -> Command.t``
Draw a point
`color` : the color of the point; default is black
`pen` : the pen used to draw the pen; default is `Brush.Pen.default`