(** from: ocaml-ageom.git *) type point2d = int * int (* (x, y) *) type vector2d = int * int (* (x, y) *) module Point2d = struct type t = point2d end module Vector2d = struct type t = vector2d let add (ax, ay) (bx, by) = (ax + bx, ay + by) let sub (ax, ay) (bx, by) = (ax - bx, ay - by) let mul (x, y) k = (x * k, y * k) let div (x, y) k = (x / k, y / k) module Infix = struct let ( +. ) = add ;; let ( -. ) = sub ;; let ( *. ) = mul ;; let ( /. ) = div ;; end end let interval = (0, 1000) module Curves2d = struct module Bezier = struct module Linear = struct let pnt (p1, p2) t = let ti = 1000 - t in Vector2d.Infix.( ( (p1 *. ti) +. (p2 *. t) ) /. 1000 ) end end end