-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommon.h
More file actions
55 lines (46 loc) · 1.67 KB
/
common.h
File metadata and controls
55 lines (46 loc) · 1.67 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef RECONSTRUCTION_RATE_TEST__COMMON_H_
#define RECONSTRUCTION_RATE_TEST__COMMON_H_
#include <fstream>
std::vector<float> arange(float l, float r, float step) {
std::vector<float> result;
float currentPos = l;
while(currentPos <= r) {
result.push_back(currentPos);
currentPos += step;
}
return result;
}
std::vector<float> linspace(float l, float r, unsigned n) {
std::vector<float> result(n, 0.0f);
float step = (r-l)/(float)(n-1);
float currentAngle = l;
for(int i = 0; i < n; ++i) {
result[i] = currentAngle;
currentAngle += step;
}
return result;
}
void writeDataToFile(const std::string& path, char* dataPtr, size_t nBytes) {
std::cerr << "NOTE: writing data to file - it make impact processing performance" << std::endl;
std::ofstream file;
file.open(path, std::ios_base::binary);
file.write((char*)dataPtr, nBytes);
file.close();
}
std::vector<float> getLinearTGCCurve(float tgcStart, float tgcSlope,
float samplingFrequency,
float speedOfSound,
float sampleRangeEnd) {
std::vector<float> tgcCurve;
float startDepth = 300.0f/samplingFrequency*speedOfSound;
float endDepth = sampleRangeEnd/samplingFrequency*speedOfSound;
float tgcSamplingStep = 150.0f/samplingFrequency*speedOfSound;
float currentDepth = startDepth;
while(currentDepth < endDepth) {
float tgcValue = tgcStart+tgcSlope*currentDepth;
tgcCurve.push_back(tgcValue);
currentDepth += tgcSamplingStep;
}
return tgcCurve;
}
#endif //RECONSTRUCTION_RATE_TEST__COMMON_H_