Skip to content

Commit bfae679

Browse files
committed
added a hack to get around tikZ's size limitation of 500.
The scaling trick to avoid decimal points wont work
1 parent 2e7691b commit bfae679

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

scripts/postProcExtPure.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,21 @@ REP="${REP//+(
1212

1313
sed -i "s/$ORIG/$REP/g" $1
1414

15+
16+
17+
# what if this line was in a string?
18+
ORIG="ztoString = PleaseFixMe"
19+
REP="ztoString x =
20+
let (q,r) = Prelude.quotRem x 100 in
21+
let rs = (Prelude.show (Prelude.abs r)) in
22+
let rss = (if ((Prelude.<) (Prelude.abs r) 10) then Prelude.concat [\"0\",rs] else rs) in
23+
let out = Prelude.concat [(Prelude.show q), \".\",rss] in
24+
(if ((Prelude.\&\&) ((Prelude.==) q 0) ((Prelude.<) r 0)) then Prelude.concat [\"-\", out] else out)"
25+
26+
REP="${REP//+(
27+
)/\\n}"
28+
29+
sed -i "s/$ORIG/$REP/g" $1
30+
1531
echo "main :: GHC.Base.IO ()
1632
main = Prelude.putStrLn toPrint" >> $1

src/robots/ackermannSteeringSimulator.v

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ Section LineRounding.
118118
1.5-eps and 1.5+eps may be rounded to 1 or 2. *)
119119
Variable eps: Qpos.
120120

121+
Global Instance CastZCR : Cast Z CR := fun x => inject_Q_CR (inject_Z x).
122+
123+
Definition finerRes : Z := 100.
124+
121125
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 |}.
123127

124128
Definition roundLineRZ (p: Line2D CR) : Line2D Z :=
125129
{|lstart := roundPointRZ (lstart p); lend:=roundPointRZ (lend p) |}.
@@ -137,17 +141,17 @@ Require ExtrHaskellNatNum.
137141
Axiom ZtoString : Z -> string.
138142
(** [Z] maps to [Prelude.Integer] and [string] map to Prelude.?? .
139143
So Prelude.show works *)
140-
Extract Constant ZtoString => "Prelude.show".
141-
144+
Extract Constant ZtoString => "PleaseFixMe".
142145
Definition sconcat (l:list string) : string :=
143146
List.fold_left append l EmptyString.
144147

145148

146149
Definition newLineChar : Ascii.ascii := Ascii.ascii_of_nat 10.
147150
Definition newLineString : string := String newLineChar EmptyString.
148151

152+
149153
Definition tikZPoint (p: Cart2D Z) : string :=
150-
"(" ++ ZtoString (X p) ++ "," ++ ZtoString (Y p) ++ ")".
154+
"(" ++ ZtoString ((X p)) ++ "," ++ ZtoString (Y p) ++ ")".
151155

152156
Definition tikZLine (l: Line2D Z) : string :=
153157
"\draw" ++ tikZPoint (lstart l) ++ "--" ++ tikZPoint (lend l) ++ ";" ++
@@ -299,7 +303,6 @@ match c with
299303
end.
300304

301305

302-
Global Instance CastZCR : Cast Z CR := fun x => inject_Q_CR (inject_Z x).
303306
Section DrawCar.
304307
Variable eps:Qpos.
305308
Variable cd :CarDimensions CR.
@@ -426,7 +429,7 @@ Local Definition wriggleMove : DAtomicMoves :=
426429

427430
(** turn radius, which is inverse of turn curvature, is 200*)
428431
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 .
430433

431434
Open Scope string_scope.
432435
Definition moveNamesWriggle : list string :=
@@ -486,13 +489,13 @@ match l with
486489
([init]++(interS)++(finerMovesStates d t midState))
487490
end.
488491

489-
Definition epsd : Z := 3.
490-
Definition textHt : Z := 25.
492+
Definition epsd : Z := 3*finerRes.
493+
Definition textHt : Z := 25*finerRes.
491494

492495
Definition Rect2D := Line2D.
493496

494497
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
496499
let ymax := Y (lend init) in
497500
let lcarMaxXY : Cart2D Z := {|X:= X (lstart b) - epsd ; Y:= ymax |} in
498501
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 :=
530533
Definition toPrint : string :=
531534
let sidewaysMove := List.zip moveNamesSideways sidewaysMove in
532535
let initStp := (sconcat spacedMoves,initSt) in
533-
let cs := (finerMovesStates 10 sidewaysMove initStp) in
536+
let cs := (finerMovesStates 3 sidewaysMove initStp) in
534537
let namedLines : list (string ** list (Line2D Z)) := carStatesFrames cs in
535538
let allLines : list (Line2D Z) := flat_map snd namedLines in
536539
let globalB := computeBoundingRectLines allLines in
@@ -547,4 +550,4 @@ Definition toPrint : string :=
547550
end.
548551
Close Scope string_scope.
549552

550-
Extraction "simulator.hs" toPrint.
553+
Extraction "simulator.hs" toPrint.

0 commit comments

Comments
 (0)