MCPcopy Create free account
hub / github.com/comaps/comaps / DoubleToUint32

Function DoubleToUint32

libs/coding/point_coding.cpp:20–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18} // namespace
19
20uint32_t DoubleToUint32(double x, double min, double max, uint8_t coordBits)
21{
22 ASSERT_LESS_OR_EQUAL(min, max, ());
23
24 double const coordSize = CoordSize(coordBits);
25
26 // Expand checks to avoid NANs when min == max.
27 double d;
28 if (x <= min)
29 d = 0;
30 else if (x >= max)
31 d = coordSize;
32 else
33 d = (x - min) / (max - min) * coordSize;
34
35 // Check in case of NANs.
36 ASSERT(d >= 0 && d <= coordSize, (d, x, min, max, coordBits));
37 return static_cast<uint32_t>(0.5 + d);
38}
39
40double Uint32ToDouble(uint32_t x, double min, double max, uint8_t coordBits)
41{

Callers 10

WriteMethod · 0.85
SerializeDataPointsV0Method · 0.85
SerializeDataPointsV1Method · 0.85
PointDToPointUFunction · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
WriteMethod · 0.85
SerializeMethod · 0.85
SerializeSpeedCameraFunction · 0.85

Calls 2

CoordSizeFunction · 0.85
ASSERTFunction · 0.85

Tested by

no test coverage detected