Collapse computeAngle into coordinate calculation
This commit is contained in:
committed by
Patrick Niklaus
parent
0fcca04150
commit
46fc6f8da4
@@ -1,37 +0,0 @@
|
||||
#ifndef COMPUTE_ANGLE_HPP
|
||||
#define COMPUTE_ANGLE_HPP
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "util/trigonometry_table.hpp"
|
||||
#include "util/mercator.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Get angle of line segment (A,C)->(C,B)
|
||||
inline double ComputeAngle(const FixedPointCoordinate first,
|
||||
const FixedPointCoordinate second,
|
||||
const FixedPointCoordinate third) noexcept
|
||||
{
|
||||
const double v1x = (first.lon - second.lon) / COORDINATE_PRECISION;
|
||||
const double v1y = mercator::latToY(first.lat / COORDINATE_PRECISION) -
|
||||
mercator::latToY(second.lat / COORDINATE_PRECISION);
|
||||
const double v2x = (third.lon - second.lon) / COORDINATE_PRECISION;
|
||||
const double v2y = mercator::latToY(third.lat / COORDINATE_PRECISION) -
|
||||
mercator::latToY(second.lat / COORDINATE_PRECISION);
|
||||
|
||||
double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180. / M_PI;
|
||||
|
||||
while (angle < 0.)
|
||||
{
|
||||
angle += 360.;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPUTE_ANGLE_HPP
|
||||
@@ -57,6 +57,11 @@ double radToDeg(const double radian);
|
||||
|
||||
double bearing(const FixedPointCoordinate &first_coordinate,
|
||||
const FixedPointCoordinate &second_coordinate);
|
||||
|
||||
// Get angle of line segment (A,C)->(C,B)
|
||||
double computeAngle(const FixedPointCoordinate &first,
|
||||
const FixedPointCoordinate &second,
|
||||
const FixedPointCoordinate &third);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user