]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - ut/pslot.t.cc
Update readme
[hubacji1/bcar.git] / ut / pslot.t.cc
1 /*
2  * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
3  *
4  * SPDX-License-Identifier: GPL-3.0-only
5  */
6
7 #include <cmath>
8 #include "wvtest.h"
9
10 #include "pslot.hh"
11
12 using namespace bcar;
13
14 WVTEST_MAIN("pslot basic geometry")
15 {
16         ParkingSlot ps(Point(1.0, 1.0), 3.0 * M_PI / 4.0, sqrt(8.0), sqrt(2.0));
17         WVPASSEQ_DOUBLE(ps.lrx(), 1.0, 0.00001);
18         WVPASSEQ_DOUBLE(ps.lry(), 1.0, 0.00001);
19         WVPASSEQ_DOUBLE(ps.rrx(), 3.0, 0.00001);
20         WVPASSEQ_DOUBLE(ps.rry(), 3.0, 0.00001);
21         WVPASSEQ_DOUBLE(ps.rfx(), 2.0, 0.00001);
22         WVPASSEQ_DOUBLE(ps.rfy(), 4.0, 0.00001);
23         WVPASSEQ_DOUBLE(ps.lfx(), 0.0, 0.00001);
24         WVPASSEQ_DOUBLE(ps.lfy(), 2.0, 0.00001);
25         WVPASS(ps.right());
26         WVPASS(!ps.parallel());
27         WVPASSEQ_DOUBLE(ps.h(), M_PI * 3.0 / 4.0, 0.00001);
28         Point p(ps.lfx(), ps.lfy());
29         ps = ParkingSlot(p, 7.0 * M_PI / 4.0, sqrt(8.0), sqrt(2.0));
30         ps.swap_side();
31         WVPASSEQ_DOUBLE(ps.lrx(), 0.0, 0.00001);
32         WVPASSEQ_DOUBLE(ps.lry(), 2.0, 0.00001);
33         WVPASSEQ_DOUBLE(ps.rrx(), 2.0, 0.00001);
34         WVPASSEQ_DOUBLE(ps.rry(), 4.0, 0.00001);
35         WVPASSEQ_DOUBLE(ps.rfx(), 3.0, 0.00001);
36         WVPASSEQ_DOUBLE(ps.rfy(), 3.0, 0.00001);
37         WVPASSEQ_DOUBLE(ps.lfx(), 1.0, 0.00001);
38         WVPASSEQ_DOUBLE(ps.lfy(), 1.0, 0.00001);
39         WVPASS(!ps.right());
40         WVPASS(!ps.parallel());
41         WVPASSEQ_DOUBLE(ps.h(), -M_PI / 4.0, 0.00001);
42 }
43
44 WVTEST_MAIN("entries")
45 {
46         ParkingSlot s(Point(0, 0), 0, 2.5, 6);
47         s.fe(BicycleCar());
48         s.compute_entries();
49         WVPASS(s._entries.size() > 0);
50         for (auto& e: s._entries) {
51                 WVPASS(s.lf().inside_of(e.ccr(), e.iradi()));
52         }
53 }