38 if (angle2id.empty()) {
41 if (angle2id.size() == 1) {
42 closestMatchingAngle = angle2id.begin()->first;
43 return angle2id.begin()->second;
46 int32_t wangle = (360 + angle) % 360;
47 type_angle2id::const_iterator u(angle2id.upper_bound(wangle));
48 type_angle2id::const_iterator tmp;
51 if (u == angle2id.end()) {
52 int32_t ud = wangle - (--u)->first;
53 int32_t ld = 360 - wangle + angle2id.begin()->first;
56 closestMatchingAngle = angle2id.begin()->first;
57 return angle2id.begin()->second;
60 closestMatchingAngle = u->first;
65 if (u == angle2id.begin()) {
68 int32_t ld = u->first - wangle;
69 int32_t ud = 360 - tmp->first + wangle;
72 closestMatchingAngle = angle2id.begin()->first;
73 return angle2id.begin()->second;
76 closestMatchingAngle = tmp->first;
81 int32_t ud = u->first - wangle;
82 int32_t ucm = u->first;
83 int32_t ui = u->second;
85 int32_t ld = wangle - u->first;
86 int32_t lcm = u->first;
87 int32_t li = u->second;
91 closestMatchingAngle = ucm;
94 closestMatchingAngle = lcm;
102 double dy = (c2.
y - c1.
y);
103 double dx = (c2.
x - c1.
x);
126 double dy = (emc2.
y - emc1.
y);
127 double dx = (emc2.
x - emc1.
x);
static T ATan2(T _x, T _y)
int32_t getAngleBetween(const Location &loc1, const Location &loc2)
Gets angle of vector defined by given locations.
Layer * getLayer() const
Gets the layer where this location is pointing to.
void setMapCoordinates(const ExactModelCoordinate &coordinates)
Sets map coordinates to this location.
const double getRotation() const
Get the cellgrid rotation.
CellGrid * getCellGrid() const
Get the Cellgrid.
int32_t getIndexByAngle(int32_t angle, const type_angle2id &angle2id, int32_t &closestMatchingAngle)
Returns id for given angle from angle2id map in case there are no elements in the map...
std::map< uint32_t, int32_t > type_angle2id
ExactModelCoordinate getMapCoordinates() const
Gets map coordinates set to this location.
Location getFacing(const Location &loc, const int32_t angle)
Gets facing location defined by given angle and location.