6663b6c9
adorian
projet complet av...
|
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
|
#include "curve_view_range.h"
#include <cmath>
#include <ion.h>
#include <assert.h>
#include <stddef.h>
#include <float.h>
namespace Shared {
uint32_t CurveViewRange::rangeChecksum() {
float data[4] = {xMin(), xMax(), yMin(), yMax()};
size_t dataLengthInBytes = 4*sizeof(float);
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
return Ion::crc32((uint32_t *)data, dataLengthInBytes/sizeof(uint32_t));
}
float CurveViewRange::yGridUnit() {
return 0.0f;
}
float CurveViewRange::computeGridUnit(Axis axis, float min, float max) {
int a = 0;
int b = 0;
float d = max - min;
float maxNumberOfUnits = k_maxNumberOfXGridUnits;
float minNumberOfUnits = k_minNumberOfXGridUnits;
if (axis == Axis::Y) {
maxNumberOfUnits = k_maxNumberOfYGridUnits;
minNumberOfUnits = k_minNumberOfYGridUnits;
}
float units[3] = {k_smallGridUnitMantissa, k_mediumGridUnitMantissa, k_largeGridUnitMantissa};
for (int k = 0; k < 3; k++) {
float unit = units[k];
if (std::floor(std::log10(d/(unit*maxNumberOfUnits))) != std::floor(std::log10(d/(unit*minNumberOfUnits)))) {
b = std::floor(std::log10(d/(unit*minNumberOfUnits)));
a = unit;
}
}
return a*std::pow(10.0f,b);
}
}
|