This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "krobot".
The branch, master has been updated
via 1005cb05df3f739bc9c6002e002a5b4eb5956c4a (commit)
from 239dbffd5fba4a3b3e9b1c3a96306914523dba14 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1005cb05df3f739bc9c6002e002a5b4eb5956c4a
Author: Jérémie Dimino <je...@di...>
Date: Tue Apr 5 22:21:48 2011 +0200
[krobot_viewer] add bezier curves for the first and last points of the trajectory
-----------------------------------------------------------------------
Changes:
diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml
index 22a5c20..7406bc0 100644
--- a/info/control2011/src/tools/krobot_viewer.ml
+++ b/info/control2011/src/tools/krobot_viewer.ml
@@ -479,6 +479,19 @@ module Board = struct
let result = List.tl (loop [0; Array.length points - 1]); in
board.points <- List.map (fun i -> points.(i)) result;
+ let bezier_vertices q r v1 v2 =
+ (* Create the bezier curve. *)
+ let curve = Bezier.of_vertices q (translate q v1) (translate r v2) r in
+
+ (* Create vertices. *)
+ let vertices = Array.create 101 origin in
+ for i = 0 to 100 do
+ vertices.(i) <- Bezier.vertice curve (float i /. 100.)
+ done;
+
+ vertices
+ in
+
(* Compute cubic bezier curves. *)
let rec loop = function
| p :: (q :: r :: s :: _ as rest) ->
@@ -487,21 +500,34 @@ module Board = struct
let _, v1 = tangents p q r and v2, _ = tangents q r s in
let v1 = v1 *| (min (distance p q) (distance q r) /. 2.)
and v2 = v2 *| (min (distance q r) (distance r s) /. 2.) in
-
- (* Create the bezier curve. *)
- let curve = Bezier.of_vertices q (translate q v1) (translate r v2) r in
-
- (* Create vertices. *)
- let vertices = Array.create 101 origin in
- for i = 0 to 100 do
- vertices.(i) <- Bezier.vertice curve (float i /. 100.)
- done;
-
- vertices :: loop rest
+ bezier_vertices q r v1 v2 :: loop rest
+ | [p; q; r] ->
+ let _, v1 = tangents p q r and v2 = vector r q /| distance q r in
+ let v1 = v1 *| (min (distance p q) (distance q r) /. 2.)
+ and v2 = v2 *| (distance q r /. 2.) in
+ [bezier_vertices q r v1 v2]
| _ ->
[]
in
- board.bezier <- [||] :: loop ({ x = board.state.pos.x; y = board.state.pos.y } :: board.points);
+ begin
+ match board.points with
+ | r :: s :: _ ->
+ let q = board.state.pos in
+ let v1 = { vx = cos board.state.theta; vy = sin board.state.theta }
+ and v2, _ = tangents q r s in
+ let v1 = v1 *| (distance q r /. 2.)
+ and v2 = v2 *| (distance q r /. 2.) in
+ board.bezier <- bezier_vertices q r v1 v2 :: loop (q :: board.points);
+ | [r] ->
+ let q = board.state.pos in
+ let v1 = { vx = cos board.state.theta; vy = sin board.state.theta }
+ and v2 = vector r q /| distance q r in
+ let v1 = v1 *| (distance q r /. 2.)
+ and v2 = v2 *| (distance q r /. 2.) in
+ board.bezier <- bezier_vertices q r v1 v2 :: loop (q :: board.points);
+ | [] ->
+ board.bezier <- []
+ end;
queue_draw board
hooks/post-receive
--
krobot
|