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