]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blobdiff - src/gen_for_gnuplot.cc
I wanted show left rear axle instead ...
[hubacji1/bcar.git] / src / gen_for_gnuplot.cc
index a2b02e41f05333afde98471f5168a19d726983fc..c15a4aace257989a8d97ee97a9a11af1bd215b47 100644 (file)
 #include "pslot.hh"
 
 #define SP 0.5
-#define STEPS 10
+#define STEPS 60
 
 #define V v
 #define INIT_V vector<M> V;
 #define P(W) V.push_back(M(#W)); V.back().o.W = true;
+#define LC V.back().c
 
 class M {
 public:
+       static unsigned int cntr;
        std::string fn;
+       std::string fc;
        std::ofstream f;
        bcar::BicycleCar c;
        bcar::BicycleCar::GenPlotOpts o;
@@ -35,14 +38,14 @@ public:
        }
        M(std::string fn) : fn(fn)
        {
-               this->f.open(this->fn);
-               this->c.sp(SP);
-               this->c.set_max_steer();
+               this->fc = std::to_string(this->cntr++);
+               this->f.open(this->fn + this->fc);
                this->o.ALL = false;
        }
        M(M const& m) : fn(m.fn), c(m.c), o(m.o)
        {
-               this->f.open(this->fn);
+               this->fc = std::to_string(this->cntr++);
+               this->f.open(this->fn + this->fc);
        }
        M& operator=(M m)
        {
@@ -55,19 +58,21 @@ public:
                f.f.close();
                t.f.close();
                swap(f.fn, t.fn);
+               swap(f.fc, t.fc);
                swap(f.c, t.c);
                swap(f.o, t.o);
-               f.f.open(f.fn);
-               t.f.open(t.fn);
+               f.f.open(f.fn + f.fc);
+               t.f.open(t.fn + t.fc);
        }
        M(M&& m) noexcept
        {
                swap(*this, m);
        }
 };
+unsigned int M::cntr = 0;
 
 void
-gpl_slot(bcar::ParkingSlot& s, std::string fn)
+gpl_slot(bcar::ParkingSlot& s, std::string fn = "")
 {
        if (fn.compare("") == 0) {
                return;
@@ -86,13 +91,15 @@ gen_pl_script(std::vector<M>& ms, std::string with_slot)
        ofstream f;
        f.open("plot.pl");
        f << "#!/usr/bin/gnuplot" << endl;
+       f << "unset key" << endl;
        f << "set size ratio -1" << endl;
-       f << "plot";
-       for (auto& m: ms) {
-               f << " '" << m.fn << "'" << " w l,";
-       }
        if (with_slot.compare("") != 0) {
-               f << " '" << with_slot << "' w l";
+               f << "plot '" << with_slot << "' w l,";
+       } else {
+               f << "plot";
+       }
+       for (auto& m: ms) {
+               f << " '" << (m.fn + m.fc) << "'" << " w l,";
        }
        f << endl;
        f << "pause -1" << endl;
@@ -110,13 +117,17 @@ main()
        string sn("slot");
        gpl_slot(s, sn);
 
-       INIT_V
-       P(LF_POINT)
-       P(LFM_POINT)
-       P(RF_POINT)
-       P(RFM_POINT)
-       P(CRA_POINT)
+       s.fe(bcar::BicycleCar());
+       s.compute_entries();
 
+       INIT_V
+       for (auto e: s._entries) {
+               P(RRA_POINT)
+               LC = e;
+               LC.st(LC.st() * -1.0);
+               P(LRA_POINT)
+               LC = e;
+       }
        for (unsigned int i = 0; i < STEPS; i++) {
                for (auto& m: V) {
                        m.gpl();