package ocaml-canvas

  1. Overview
  2. Docs

Point manipulation functions

type t = float * float

A point is a pair of floats of the form (x, y)

val of_ints : (int * int) -> t

of_ints (x, y) creates a point from integer coordinates

val sub : t -> t -> Vector.t

sub p1 p2 returns the difference between points p1 and p2

val translate : t -> by:Vector.t -> t

translate p ~by translates point p by vector by

val rotate : t -> around:t -> theta:float -> t

rotate p ~around ~theta rotates point p around a central point around by an angle theta

val transform : t -> Transform.t -> t

transform p t transforms point p by the given transform t

val barycenter : float -> t -> float -> t -> t

barycenter a p1 b p2 compute the barycenter of (a, p1) and (b, p2)

Exceptions:

val distance : t -> t -> float

distance p1 p2 computes the distance between p1 and p2

OCaml

Innovation. Community. Security.