-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroadpoint.h
43 lines (37 loc) · 1.12 KB
/
roadpoint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef ROADPOINT_H
#define ROADPOINT_H
#include "mymath.h"
struct RoadPoint
{
QPointF pos;
int level;
RoadPoint() = default;
RoadPoint(QPointF pos, int level);
RoadPoint(RoadPoint& point) = default;
RoadPoint(const RoadPoint& point) = default;
RoadPoint(RoadPoint&& point) = default;
inline bool operator<(RoadPoint const& other) const
{
if (this->level != other.level)
{
return this->level < other.level;
}
auto firstLength = vectorLength(this->pos);
auto secondLength = vectorLength(other.pos);
if (isEqual(firstLength, secondLength))
{
auto firstAngle = vectorAngle(this->pos);
auto secondAngle = vectorAngle(other.pos);
return firstAngle < secondAngle;
}
else
{
return firstLength < secondLength;
}
}
RoadPoint& operator=(const RoadPoint &other) = default;
RoadPoint& operator=(RoadPoint &&other) = default;
bool operator==(const RoadPoint &other) const;
bool operator!=(const RoadPoint &other) const;
};
#endif // ROADPOINT_H