Points in the plane
The abstract type for points
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
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
length p
is the length of vector from the origin to p
xpart p
is the x coordinate of point p
ypart p
is the y coordinate of point p
Operations on points
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
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
Scales the X coordinate of a point by a scalar
Scales the Y coordinate of a point by a scalar
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
val ptlist : ?scale:(float -> Num.t) -> (float * float) list -> t list
Same as p
, but builds a list of points