Skip to content

Commit 1504b38

Browse files
committed
fix CRLF
1 parent 28ff7b0 commit 1504b38

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

rerun_cpp/src/rerun/demo_utils.hpp

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
#pragma once
2-
3-
// Utilities used in examples.
4-
5-
#include <algorithm>
6-
#include <cmath>
7-
#include <vector>
8-
9-
#include "components/color.hpp"
10-
#include "components/position3d.hpp"
11-
12-
namespace rerun {
13-
namespace demo {
14-
constexpr float PI = 3.14159265358979323846264338327950288f;
15-
constexpr float TAU = 6.28318530717958647692528676655900577f;
16-
17-
/// A linear interpolator that bounces between `a` and `b` as `t` goes above `1.0`.
18-
inline float bounce_lerp(float a, float b, float t) {
19-
auto tf = t - floorf(t);
20-
if (static_cast<int32_t>(t) % 2 == 0) {
21-
return (1.0f - tf) * a + tf * b;
22-
} else {
23-
return tf * a + (1.0f - tf) * b;
24-
}
25-
}
26-
27-
/// Linearly interpolates from `a` through `b` in `n` steps, returning the intermediate result at
28-
/// each step.
29-
template <typename T>
30-
inline std::vector<T> linspace(T start, T end, size_t num) {
31-
std::vector<T> linspaced(num);
32-
std::generate(linspaced.begin(), linspaced.end(), [&, i = 0]() mutable {
33-
return static_cast<T>(start + static_cast<T>(i++) * (end - start) / static_cast<T>(num - 1));
34-
});
35-
return linspaced;
36-
}
37-
38-
/// Given two 3D vectors `from` and `to`, linearly interpolates between them in `n` steps along
39-
/// the three axes, returning the intermediate result at each step.
40-
template <typename T, typename Elem>
41-
std::vector<T> grid(std::array<Elem, 3> from, std::array<Elem, 3> to, size_t n) {
42-
std::vector<T> output;
43-
for (Elem z : linspace(from[0], to[0], n)) {
44-
for (Elem y : linspace(from[1], to[1], n)) {
45-
for (Elem x : linspace(from[2], to[2], n)) {
46-
output.emplace_back(
47-
static_cast<Elem>(x),
48-
static_cast<Elem>(y),
49-
static_cast<Elem>(z)
50-
);
51-
}
52-
}
53-
}
54-
return output;
55-
}
56-
57-
/// Create a spiral of points with colors along the Z axis.
58-
///
59-
/// * `num_points`: Total number of points.
60-
/// * `radius`: The radius of the spiral.
61-
/// * `angular_step`: The factor applied between each step along the trigonometric circle.
62-
/// * `angular_offset`: Offsets the starting position on the trigonometric circle.
63-
/// * `z_step`: The factor applied between between each step along the Z axis.
64-
void color_spiral(
65-
size_t num_points, float radius, float angular_step, float angular_offset, float z_step,
66-
std::vector<components::Position3D>& out_points,
67-
std::vector<components::Color>& out_colors
68-
);
69-
70-
/// Returns sRGB polynomial approximation from Turbo color map, assuming `t` is normalized.
71-
rerun::components::Color colormap_turbo_srgb(float t);
72-
} // namespace demo
73-
} // namespace rerun
1+
#pragma once
2+
3+
// Utilities used in examples.
4+
5+
#include <algorithm>
6+
#include <cmath>
7+
#include <vector>
8+
9+
#include "components/color.hpp"
10+
#include "components/position3d.hpp"
11+
12+
namespace rerun {
13+
namespace demo {
14+
constexpr float PI = 3.14159265358979323846264338327950288f;
15+
constexpr float TAU = 6.28318530717958647692528676655900577f;
16+
17+
/// A linear interpolator that bounces between `a` and `b` as `t` goes above `1.0`.
18+
inline float bounce_lerp(float a, float b, float t) {
19+
auto tf = t - floorf(t);
20+
if (static_cast<int32_t>(t) % 2 == 0) {
21+
return (1.0f - tf) * a + tf * b;
22+
} else {
23+
return tf * a + (1.0f - tf) * b;
24+
}
25+
}
26+
27+
/// Linearly interpolates from `a` through `b` in `n` steps, returning the intermediate result at
28+
/// each step.
29+
template <typename T>
30+
inline std::vector<T> linspace(T start, T end, size_t num) {
31+
std::vector<T> linspaced(num);
32+
std::generate(linspaced.begin(), linspaced.end(), [&, i = 0]() mutable {
33+
return static_cast<T>(start + static_cast<T>(i++) * (end - start) / static_cast<T>(num - 1));
34+
});
35+
return linspaced;
36+
}
37+
38+
/// Given two 3D vectors `from` and `to`, linearly interpolates between them in `n` steps along
39+
/// the three axes, returning the intermediate result at each step.
40+
template <typename T, typename Elem>
41+
std::vector<T> grid(std::array<Elem, 3> from, std::array<Elem, 3> to, size_t n) {
42+
std::vector<T> output;
43+
for (Elem z : linspace(from[0], to[0], n)) {
44+
for (Elem y : linspace(from[1], to[1], n)) {
45+
for (Elem x : linspace(from[2], to[2], n)) {
46+
output.emplace_back(
47+
static_cast<Elem>(x),
48+
static_cast<Elem>(y),
49+
static_cast<Elem>(z)
50+
);
51+
}
52+
}
53+
}
54+
return output;
55+
}
56+
57+
/// Create a spiral of points with colors along the Z axis.
58+
///
59+
/// * `num_points`: Total number of points.
60+
/// * `radius`: The radius of the spiral.
61+
/// * `angular_step`: The factor applied between each step along the trigonometric circle.
62+
/// * `angular_offset`: Offsets the starting position on the trigonometric circle.
63+
/// * `z_step`: The factor applied between between each step along the Z axis.
64+
void color_spiral(
65+
size_t num_points, float radius, float angular_step, float angular_offset, float z_step,
66+
std::vector<components::Position3D>& out_points,
67+
std::vector<components::Color>& out_colors
68+
);
69+
70+
/// Returns sRGB polynomial approximation from Turbo color map, assuming `t` is normalized.
71+
rerun::components::Color colormap_turbo_srgb(float t);
72+
} // namespace demo
73+
} // namespace rerun

0 commit comments

Comments
 (0)