]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - src/pslot.cc
Move sgn template to header file
[hubacji1/bcar.git] / src / pslot.cc
1 #include <cmath>
2 #include "pslot.h"
3
4 // slot info
5 double ParkingSlot::heading() const
6 {
7         return atan2(this->y4() - this->y1(), this->x4() - this->x1());
8 }
9
10 bool ParkingSlot::parallel() const
11 {
12         double d1 = sqrt(
13                 pow(this->x2() - this->x1(), 2)
14                 + pow(this->y2() - this->y1(), 2)
15         );
16         double d2 = sqrt(
17                 pow(this->x3() - this->x2(), 2)
18                 + pow(this->y3() - this->y2(), 2)
19         );
20         if (d1 < d2)
21                 return true;
22         else
23                 return false;
24 }
25
26 bool ParkingSlot::right() const
27 {
28         if (sgn(
29                 (this->x2() - this->x1()) * (this->y4() - this->y1())
30                 - (this->y2() - this->y1()) * (this->x4() - this->x1())
31         ) < 0)
32                 return false;
33         else
34                 return true;
35 }
36
37 ParkingSlot::ParkingSlot()
38 {
39 }