Rerun C++ SDK
Loading...
Searching...
No Matches
transform3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/transform3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../components/axis_length.hpp"
9#include "../components/transform3d.hpp"
10#include "../data_cell.hpp"
11#include "../indicator_component.hpp"
12#include "../rerun_sdk_export.hpp"
13#include "../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::archetypes {
21 /// **Archetype**: A 3D transform.
22 ///
23 /// ## Example
24 ///
25 /// ### Variety of 3D transforms
26 /// ![image](https://static.rerun.io/transform3d_simple/141368b07360ce3fcb1553079258ae3f42bdb9ac/full.png)
27 ///
28 /// ```cpp
29 /// #include <rerun.hpp>
30 ///
31 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
32 ///
33 /// int main() {
34 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d");
35 /// rec.spawn().exit_on_failure();
36 ///
37 /// auto arrow =
38 /// rerun::Arrows3D::from_vectors({{0.0f, 1.0f, 0.0f}}).with_origins({{0.0f, 0.0f, 0.0f}});
39 ///
40 /// rec.log("base", arrow);
41 ///
42 /// rec.log("base/translated", rerun::Transform3D({1.0f, 0.0f, 0.0f}));
43 /// rec.log("base/translated", arrow);
44 ///
45 /// rec.log(
46 /// "base/rotated_scaled",
47 /// rerun::Transform3D(
48 /// rerun::RotationAxisAngle({0.0f, 0.0f, 1.0f}, rerun::Angle::radians(TAU / 8.0f)),
49 /// 2.0f
50 /// )
51 /// );
52 /// rec.log("base/rotated_scaled", arrow);
53 /// }
54 /// ```
55 struct Transform3D {
56 /// The transform
58
59 /// Visual length of the 3 axes.
60 ///
61 /// The length is interpreted in the local coordinate system of the transform.
62 /// If the transform is scaled, the axes will be scaled accordingly.
63 std::optional<rerun::components::AxisLength> axis_length;
64
65 public:
66 static constexpr const char IndicatorComponentName[] =
67 "rerun.components.Transform3DIndicator";
68
69 /// Indicator component, used to identify the archetype when converting to a list of components.
71
72 public:
73 // Extensions to generated type defined in 'transform3d_ext.cpp'
74
75 /// Identity transformation.
76 ///
77 /// Applying this transform does not alter an entity's transformation.
78 RERUN_SDK_EXPORT static const Transform3D IDENTITY;
79
80 /// New 3D transform from translation/matrix datatype.
81 ///
82 /// \param translation_and_mat3x3 Combined translation/matrix.
83 Transform3D(const datatypes::TranslationAndMat3x3& translation_and_mat3x3)
84 : Transform3D(datatypes::Transform3D::translation_and_mat3x3(translation_and_mat3x3)) {}
85
86 /// Creates a new 3D transform from translation and matrix provided as 3 columns.
87 ///
88 /// \param translation \çopydoc datatypes::TranslationAndMat3x3::translation
89 /// \param columns Column vectors of 3x3 matrix.
90 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
91 ///
92 /// _Implementation note:_ This overload is necessary, otherwise the array may be
93 /// interpreted as bool and call the wrong overload.
95 const datatypes::Vec3D& translation, const datatypes::Vec3D (&columns)[3],
96 bool from_parent = false
97 )
98 : Transform3D(datatypes::TranslationAndMat3x3(translation, columns, from_parent)) {}
99
100 /// Creates a new 3D transform from translation/matrix.
101 ///
102 /// \param translation \çopydoc datatypes::TranslationAndMat3x3::translation
103 /// \param matrix \copydoc datatypes::TranslationAndMat3x3::mat3x3
104 /// \param from_parent \copydoc datatypes::TranslationAndMat3x3::from_parent
106 const datatypes::Vec3D& translation, const datatypes::Mat3x3& matrix,
107 bool from_parent = false
108 )
109 : Transform3D(datatypes::TranslationAndMat3x3(translation, matrix, from_parent)) {}
110
111 /// From translation only.
112 ///
113 /// \param translation \çopydoc datatypes::TranslationRotationScale3D::translation
114 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
115 Transform3D(const datatypes::Vec3D& translation, bool from_parent = false)
116 : Transform3D(datatypes::TranslationRotationScale3D(translation, from_parent)) {}
117
118 /// From 3x3 matrix only.
119 ///
120 /// \param matrix \copydoc datatypes::TranslationAndMat3x3::mat3x3
121 /// \param from_parent \copydoc datatypes::TranslationAndMat3x3::from_parent
122 Transform3D(const datatypes::Mat3x3& matrix, bool from_parent = false)
123 : Transform3D(datatypes::TranslationAndMat3x3(matrix, from_parent)) {}
124
125 /// From 3x3 matrix provided as 3 columns only.
126 ///
127 /// \param columns Column vectors of 3x3 matrix.
128 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
129 Transform3D(const datatypes::Vec3D (&columns)[3], bool from_parent = false)
130 : Transform3D(datatypes::TranslationAndMat3x3(columns, from_parent)) {}
131
132 /// New 3D transform from translation/rotation/scale datatype.
133 /// \param translation_rotation_scale3d Combined translation/rotation/scale.
134 Transform3D(const datatypes::TranslationRotationScale3D& translation_rotation_scale3d)
135 : Transform3D(
136 datatypes::Transform3D::translation_rotation_scale(translation_rotation_scale3d)
137 ) {}
138
139 /// Creates a new 3D transform from translation/rotation/scale.
140 ///
141 /// \param translation \copydoc datatypes::TranslationRotationScale3D::translation
142 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
143 /// \param scale \copydoc datatypes::TranslationRotationScale3D::scale
144 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
146 const datatypes::Vec3D& translation, const datatypes::Rotation3D& rotation,
147 const datatypes::Scale3D& scale, bool from_parent = false
148 )
149 : Transform3D(
150 datatypes::TranslationRotationScale3D(translation, rotation, scale, from_parent)
151 ) {}
152
153 /// Creates a new 3D transform from translation/rotation/uniform-scale.
154 ///
155 /// \param translation \copydoc datatypes::TranslationRotationScale3D::translation
156 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
157 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
158 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
159 ///
160 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
161 /// bool, leading to a call to the wrong overload.
163 const datatypes::Vec3D& translation, const datatypes::Rotation3D& rotation,
164 float uniform_scale, bool from_parent = false
165 )
167 translation, rotation, uniform_scale, from_parent
168 )) {}
169
170 /// Creates a new rigid transform (translation & rotation only).
171 ///
172 /// \param translation \copydoc datatypes::TranslationRotationScale3D::translation
173 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
174 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
176 const datatypes::Vec3D& translation, const datatypes::Rotation3D& rotation,
177 bool from_parent = false
178 )
179 : Transform3D(datatypes::TranslationRotationScale3D(translation, rotation, from_parent)
180 ) {}
181
182 /// From translation & scale only.
183 ///
184 /// \param translation \copydoc datatypes::TranslationRotationScale3D::translation
185 /// \param scale datatypes::TranslationRotationScale3D::scale
186 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
188 const datatypes::Vec3D& translation, const datatypes::Scale3D& scale,
189 bool from_parent = false
190 )
191 : Transform3D(datatypes::TranslationRotationScale3D(translation, scale, from_parent)) {}
192
193 /// From translation & uniform scale only.
194 ///
195 /// \param translation \copydoc datatypes::TranslationRotationScale3D::translation
196 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
197 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
198 ///
199 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
200 /// bool, leading to a call to the wrong overload.
202 const datatypes::Vec3D& translation, float uniform_scale, bool from_parent = false
203 )
204 : Transform3D(
205 datatypes::TranslationRotationScale3D(translation, uniform_scale, from_parent)
206 ) {}
207
208 /// From rotation & scale.
209 ///
210 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
211 /// \param scale datatypes::TranslationRotationScale3D::scale
212 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
214 const datatypes::Rotation3D& rotation, const datatypes::Scale3D& scale,
215 bool from_parent = false
216 )
217 : Transform3D(datatypes::TranslationRotationScale3D(rotation, scale, from_parent)) {}
218
219 /// From rotation & uniform scale.
220 ///
221 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
222 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
223 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
224 ///
225 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
226 /// bool, leading to a call to the wrong overload.
228 const datatypes::Rotation3D& rotation, float uniform_scale, bool from_parent = false
229 )
230 : Transform3D(
231 datatypes::TranslationRotationScale3D(rotation, uniform_scale, from_parent)
232 ) {}
233
234 /// From rotation only.
235 ///
236 /// \param rotation \copydoc datatypes::TranslationRotationScale3D::rotation
237 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::from_parent
238 Transform3D(const datatypes::Rotation3D& rotation, bool from_parent = false)
239 : Transform3D(datatypes::TranslationRotationScale3D(rotation, from_parent)) {}
240
241 /// From scale only.
242 ///
243 /// \param scale \copydoc datatypes::TranslationRotationScale3D::from_parent
244 /// \param from_parent \copydoc datatypes::TranslationRotationScale3D::scale
245 Transform3D(const datatypes::Scale3D& scale, bool from_parent = false)
246 : Transform3D(datatypes::TranslationRotationScale3D(scale, from_parent)) {}
247
248 public:
249 Transform3D() = default;
250 Transform3D(Transform3D&& other) = default;
251
253 : transform(std::move(_transform)) {}
254
255 /// Visual length of the 3 axes.
256 ///
257 /// The length is interpreted in the local coordinate system of the transform.
258 /// If the transform is scaled, the axes will be scaled accordingly.
260 axis_length = std::move(_axis_length);
261 // See: https://github.com/rerun-io/rerun/issues/4027
262 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
263 }
264 };
265
266} // namespace rerun::archetypes
267
268namespace rerun {
269 /// \private
270 template <typename T>
271 struct AsComponents;
272
273 /// \private
274 template <>
275 struct AsComponents<archetypes::Transform3D> {
276 /// Serialize all set component batches.
277 static Result<std::vector<DataCell>> serialize(const archetypes::Transform3D& archetype);
278 };
279} // namespace rerun
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:72
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Archetype: A 3D transform.
Definition transform3d.hpp:55
Transform3D(const datatypes::Vec3D &translation, const datatypes::Rotation3D &rotation, float uniform_scale, bool from_parent=false)
Creates a new 3D transform from translation/rotation/uniform-scale.
Definition transform3d.hpp:162
static RERUN_SDK_EXPORT const Transform3D IDENTITY
Identity transformation.
Definition transform3d.hpp:78
std::optional< rerun::components::AxisLength > axis_length
Visual length of the 3 axes.
Definition transform3d.hpp:63
Transform3D(const datatypes::Vec3D(&columns)[3], bool from_parent=false)
From 3x3 matrix provided as 3 columns only.
Definition transform3d.hpp:129
Transform3D(const datatypes::Rotation3D &rotation, const datatypes::Scale3D &scale, bool from_parent=false)
From rotation & scale.
Definition transform3d.hpp:213
Transform3D with_axis_length(rerun::components::AxisLength _axis_length) &&
Visual length of the 3 axes.
Definition transform3d.hpp:259
Transform3D(const datatypes::Vec3D &translation, const datatypes::Vec3D(&columns)[3], bool from_parent=false)
Creates a new 3D transform from translation and matrix provided as 3 columns.
Definition transform3d.hpp:94
Transform3D(const datatypes::Vec3D &translation, const datatypes::Scale3D &scale, bool from_parent=false)
From translation & scale only.
Definition transform3d.hpp:187
Transform3D(const datatypes::Vec3D &translation, float uniform_scale, bool from_parent=false)
From translation & uniform scale only.
Definition transform3d.hpp:201
Transform3D(const datatypes::Scale3D &scale, bool from_parent=false)
From scale only.
Definition transform3d.hpp:245
Transform3D(const datatypes::TranslationRotationScale3D &translation_rotation_scale3d)
New 3D transform from translation/rotation/scale datatype.
Definition transform3d.hpp:134
Transform3D(const datatypes::TranslationAndMat3x3 &translation_and_mat3x3)
New 3D transform from translation/matrix datatype.
Definition transform3d.hpp:83
Transform3D(const datatypes::Mat3x3 &matrix, bool from_parent=false)
From 3x3 matrix only.
Definition transform3d.hpp:122
Transform3D(const datatypes::Vec3D &translation, const datatypes::Mat3x3 &matrix, bool from_parent=false)
Creates a new 3D transform from translation/matrix.
Definition transform3d.hpp:105
Transform3D(const datatypes::Vec3D &translation, bool from_parent=false)
From translation only.
Definition transform3d.hpp:115
Transform3D(const datatypes::Rotation3D &rotation, float uniform_scale, bool from_parent=false)
From rotation & uniform scale.
Definition transform3d.hpp:227
rerun::components::Transform3D transform
The transform.
Definition transform3d.hpp:57
Transform3D(const datatypes::Vec3D &translation, const datatypes::Rotation3D &rotation, bool from_parent=false)
Creates a new rigid transform (translation & rotation only).
Definition transform3d.hpp:175
Transform3D(const datatypes::Rotation3D &rotation, bool from_parent=false)
From rotation only.
Definition transform3d.hpp:238
Transform3D(const datatypes::Vec3D &translation, const datatypes::Rotation3D &rotation, const datatypes::Scale3D &scale, bool from_parent=false)
Creates a new 3D transform from translation/rotation/scale.
Definition transform3d.hpp:145
Component: The length of an axis in local units of the space.
Definition axis_length.hpp:14
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23
Component: An affine transform between two 3D spaces, represented in a given direction.
Definition transform3d.hpp:14
Datatype: A 3x3 Matrix.
Definition mat3x3.hpp:31
Datatype: A 3D rotation.
Definition rotation3d.hpp:60
Datatype: 3D scaling factor, part of a transform representation.
Definition scale3d.hpp:58
Datatype: Representation of an affine transform via a 3x3 affine matrix paired with a translation.
Definition translation_and_mat3x3.hpp:25
Datatype: Representation of an affine transform via separate translation, rotation & scale.
Definition translation_rotation_scale3d.hpp:25
Datatype: A vector in 3D space.
Definition vec3d.hpp:20