@@ -118,8 +118,12 @@ Section LineRounding.
118
118
1.5-eps and 1.5+eps may be rounded to 1 or 2. *)
119
119
Variable eps: Qpos.
120
120
121
+ Global Instance CastZCR : Cast Z CR := fun x => inject_Q_CR (inject_Z x).
122
+
123
+ Definition finerRes : Z := 100.
124
+
121
125
Definition roundPointRZ (p: Cart2D CR) : Cart2D Z :=
122
- {|X:= R2ZApprox (X p) eps; Y:=R2ZApprox (Y p) eps |}.
126
+ {|X:= R2ZApprox ('finerRes * ( X p)) eps; Y:=R2ZApprox ('finerRes * ( Y p) ) eps |}.
123
127
124
128
Definition roundLineRZ (p: Line2D CR) : Line2D Z :=
125
129
{|lstart := roundPointRZ (lstart p); lend:=roundPointRZ (lend p) |}.
@@ -137,17 +141,17 @@ Require ExtrHaskellNatNum.
137
141
Axiom ZtoString : Z -> string.
138
142
(** [Z] maps to [Prelude.Integer] and [string] map to Prelude.?? .
139
143
So Prelude.show works *)
140
- Extract Constant ZtoString => "Prelude.show".
141
-
144
+ Extract Constant ZtoString => "PleaseFixMe".
142
145
Definition sconcat (l:list string) : string :=
143
146
List.fold_left append l EmptyString.
144
147
145
148
146
149
Definition newLineChar : Ascii.ascii := Ascii.ascii_of_nat 10.
147
150
Definition newLineString : string := String newLineChar EmptyString.
148
151
152
+
149
153
Definition tikZPoint (p: Cart2D Z) : string :=
150
- "(" ++ ZtoString (X p) ++ "," ++ ZtoString (Y p) ++ ")".
154
+ "(" ++ ZtoString (( X p) ) ++ "," ++ ZtoString (Y p) ++ ")".
151
155
152
156
Definition tikZLine (l: Line2D Z) : string :=
153
157
"\draw" ++ tikZPoint (lstart l) ++ "--" ++ tikZPoint (lend l) ++ ";" ++
@@ -299,7 +303,6 @@ match c with
299
303
end .
300
304
301
305
302
- Global Instance CastZCR : Cast Z CR := fun x => inject_Q_CR (inject_Z x).
303
306
Section DrawCar.
304
307
Variable eps:Qpos.
305
308
Variable cd :CarDimensions CR.
@@ -426,7 +429,7 @@ Local Definition wriggleMove : DAtomicMoves :=
426
429
427
430
(** turn radius, which is inverse of turn curvature, is 200 *)
428
431
Local Definition sidewaysMove : DAtomicMoves :=
429
- (DSideways (QposMake 1 50) (cast Z CR 5 ) (cast Z CR 15 ))%Z .
432
+ (DSideways (QposMake 1 50) (cast Z CR 15 ) (cast Z CR 10 ))%Z .
430
433
431
434
Open Scope string_scope.
432
435
Definition moveNamesWriggle : list string :=
@@ -486,13 +489,13 @@ match l with
486
489
([init]++(interS)++(finerMovesStates d t midState))
487
490
end .
488
491
489
- Definition epsd : Z := 3.
490
- Definition textHt : Z := 25.
492
+ Definition epsd : Z := 3*finerRes .
493
+ Definition textHt : Z := 25*finerRes .
491
494
492
495
Definition Rect2D := Line2D.
493
496
494
497
Definition sideCars (b init :BoundingRectangle Z): (BoundingRectangle Z) * list (Rect2D Z) :=
495
- let cardim : Cart2D Z := {|X:= (lengthFront myCarDimZ) ; Y:= 2 * (width myCarDimZ) |} in
498
+ let cardim : Cart2D Z := (sameXY finerRes)* {|X:= (lengthFront myCarDimZ) ; Y:= 2 * (width myCarDimZ) |} in
496
499
let ymax := Y (lend init) in
497
500
let lcarMaxXY : Cart2D Z := {|X:= X (lstart b) - epsd ; Y:= ymax |} in
498
501
let rcarMinXY : Cart2D Z := {|X:= X (lend b) + epsd ; Y:= ymax - (Y cardim) |} in
@@ -530,7 +533,7 @@ Definition frameWithLines (preface:string) (lines : list (Line2D Z)) : string :=
530
533
Definition toPrint : string :=
531
534
let sidewaysMove := List.zip moveNamesSideways sidewaysMove in
532
535
let initStp := (sconcat spacedMoves,initSt) in
533
- let cs := (finerMovesStates 10 sidewaysMove initStp) in
536
+ let cs := (finerMovesStates 3 sidewaysMove initStp) in
534
537
let namedLines : list (string ** list (Line2D Z)) := carStatesFrames cs in
535
538
let allLines : list (Line2D Z) := flat_map snd namedLines in
536
539
let globalB := computeBoundingRectLines allLines in
@@ -547,4 +550,4 @@ Definition toPrint : string :=
547
550
end .
548
551
Close Scope string_scope.
549
552
550
- Extraction "simulator.hs" toPrint.
553
+ Extraction "simulator.hs" toPrint.
0 commit comments