From 1aa90219e3e74bac3afbde0ec120e098b50bd0c5 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 11 Jan 2021 13:51:21 +0100 Subject: Interior curve evaluation --- path/builder.ml | 18 ++++++++++++++++++ path/builder.mli | 3 +++ path/fixed.ml | 7 ++++++- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'path') diff --git a/path/builder.ml b/path/builder.ml index 166c073..4403599 100755 --- a/path/builder.ml +++ b/path/builder.ml @@ -203,4 +203,22 @@ module Make(Point:P) = struct path ) + let map + : t -> (Point.t -> Point.t) -> t + = fun (points, beziers) f -> + let points = List.map + points + ~f + and beziers = List.map + beziers + ~f:(fun bezier -> + + { p0 = f bezier.p0 + ; p1 = f bezier.p1 + ; ctrl0 = Point.(get_coord (f ( copy bezier.p0 bezier.ctrl0))) + ; ctrl1 = Point.(get_coord (f ( copy bezier.p1 bezier.ctrl1))) + } + ) in + points, beziers + end diff --git a/path/builder.mli b/path/builder.mli index ff66bcb..2afbd4b 100755 --- a/path/builder.mli +++ b/path/builder.mli @@ -37,4 +37,7 @@ module Make(Point:P) : sig val repr : t -> (module Repr.M with type point = Point.t and type t = 's) -> 's -> 's + val map + : t -> (Point.t -> Point.t) -> t + end diff --git a/path/fixed.ml b/path/fixed.ml index d61bb0a..1362ad3 100755 --- a/path/fixed.ml +++ b/path/fixed.ml @@ -179,7 +179,12 @@ module Make(Point:P) = struct | Curve bezier -> let point = f step.point in { point - ; move = Curve {bezier with p1 = f bezier.p1} } + ; move = Curve + { p1 = f bezier.p1 + ; ctrl0 = Point.get_coord (f (Point.copy step.point bezier.ctrl0)) + ; ctrl1 = Point.get_coord (f (Point.copy bezier.p1 bezier.ctrl1)) + } + } ) let iter -- cgit v1.2.3