Rerun C++ SDK
Loading...
Searching...
No Matches
transform3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/archetypes/transform3d.def.rs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/rotation_axis_angle.hpp"
11#include "../components/rotation_quat.hpp"
12#include "../components/scale3d.hpp"
13#include "../components/transform_frame_id.hpp"
14#include "../components/transform_mat3x3.hpp"
15#include "../components/transform_relation.hpp"
16#include "../components/translation3d.hpp"
17#include "../rerun_sdk_export.hpp"
18#include "../result.hpp"
19#include "../rotation3d.hpp"
20
21#include <cstdint>
22#include <optional>
23#include <utility>
24#include <vector>
25
26namespace rerun::archetypes {
27 /// **Archetype**: A transform between two 3D spaces, i.e. a pose.
28 ///
29 /// From the point of view of the entity's coordinate system,
30 /// all components are applied in the inverse order they are listed here.
31 /// E.g. if both a translation and a mat3x3 transform are present,
32 /// the 3x3 matrix is applied first, followed by the translation.
33 ///
34 /// Whenever you log this archetype, the state of the resulting transform relationship is fully reset to the new archetype.
35 /// This means that if you first log a transform with only a translation, and then log one with only a rotation,
36 /// it will be resolved to a transform with only a rotation.
37 /// (This is unlike how we usually apply latest-at semantics on an archetype where we take the latest state of any component independently)
38 ///
39 /// For transforms that affect only a single entity and do not propagate along the entity tree refer to `archetypes::InstancePoses3D`.
40 ///
41 /// ## Examples
42 ///
43 /// ### Variety of 3D transforms
44 /// ![image](https://static.rerun.io/transform3d_simple/141368b07360ce3fcb1553079258ae3f42bdb9ac/full.png)
45 ///
46 /// ```cpp
47 /// #include <rerun.hpp>
48 ///
49 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
50 ///
51 /// int main(int argc, char* argv[]) {
52 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d");
53 /// rec.spawn().exit_on_failure();
54 ///
55 /// auto arrow = rerun::Arrows3D::from_vectors({{0.0f, 1.0f, 0.0f}})
56 /// .with_origins({{0.0f, 0.0f, 0.0f}});
57 ///
58 /// rec.log("base", arrow);
59 ///
60 /// rec.log(
61 /// "base/translated",
62 /// rerun::Transform3D::from_translation({1.0f, 0.0f, 0.0f})
63 /// );
64 /// rec.log("base/translated", arrow);
65 ///
66 /// rec.log(
67 /// "base/rotated_scaled",
68 /// rerun::Transform3D::from_rotation_scale(
69 /// rerun::RotationAxisAngle(
70 /// {0.0f, 0.0f, 1.0f},
71 /// rerun::Angle::radians(TAU / 8.0f)
72 /// ),
73 /// 2.0f
74 /// )
75 /// );
76 /// rec.log("base/rotated_scaled", arrow);
77 /// }
78 /// ```
79 ///
80 /// ### Update a transform over time
81 /// ![image](https://static.rerun.io/transform3d_column_updates/80634e1c7c7a505387e975f25ea8b6bc1d4eb9db/full.png)
82 ///
83 /// ```cpp
84 /// #include <rerun.hpp>
85 ///
86 /// float truncated_radians(int deg) {
87 /// auto degf = static_cast<float>(deg);
88 /// const auto pi = 3.14159265358979323846f;
89 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) /
90 /// 1000.0f;
91 /// }
92 ///
93 /// int main(int argc, char* argv[]) {
94 /// const auto rec =
95 /// rerun::RecordingStream("rerun_example_transform3d_row_updates");
96 /// rec.spawn().exit_on_failure();
97 ///
98 /// rec.set_time_sequence("tick", 0);
99 /// rec.log(
100 /// "box",
101 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}})
102 /// .with_fill_mode(rerun::FillMode::Solid),
103 /// rerun::TransformAxes3D(10.0)
104 /// );
105 ///
106 /// for (int t = 0; t <100; t++) {
107 /// rec.set_time_sequence("tick", t + 1);
108 /// rec.log(
109 /// "box",
110 /// rerun::Transform3D()
111 /// .with_translation({0.0f, 0.0f, static_cast<float>(t) / 10.0f})
112 /// .with_rotation_axis_angle(rerun::RotationAxisAngle(
113 /// {0.0f, 1.0f, 0.0f},
114 /// rerun::Angle::radians(truncated_radians(t * 4))
115 /// ))
116 /// );
117 /// }
118 /// }
119 /// ```
120 ///
121 /// ### Update a transform over time, in a single operation
122 /// ![image](https://static.rerun.io/transform3d_column_updates/80634e1c7c7a505387e975f25ea8b6bc1d4eb9db/full.png)
123 ///
124 /// ```cpp
125 /// #include <cmath>
126 /// #include <numeric>
127 /// #include <vector>
128 ///
129 /// #include <rerun.hpp>
130 ///
131 /// float truncated_radians(int deg) {
132 /// auto degf = static_cast<float>(deg);
133 /// const auto pi = 3.14159265358979323846f;
134 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) /
135 /// 1000.0f;
136 /// }
137 ///
138 /// int main(int argc, char* argv[]) {
139 /// const auto rec =
140 /// rerun::RecordingStream("rerun_example_transform3d_column_updates");
141 /// rec.spawn().exit_on_failure();
142 ///
143 /// rec.set_time_sequence("tick", 0);
144 /// rec.log(
145 /// "box",
146 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}})
147 /// .with_fill_mode(rerun::FillMode::Solid),
148 /// rerun::TransformAxes3D(10.0)
149 /// );
150 ///
151 /// std::vector<std::array<float, 3>> translations;
152 /// std::vector<rerun::RotationAxisAngle> rotations;
153 /// for (int t = 0; t <100; t++) {
154 /// translations.push_back({0.0f, 0.0f, static_cast<float>(t) / 10.0f});
155 /// rotations.push_back(rerun::RotationAxisAngle(
156 /// {0.0f, 1.0f, 0.0f},
157 /// rerun::Angle::radians(truncated_radians(t * 4))
158 /// ));
159 /// }
160 ///
161 /// std::vector<int64_t> ticks(100);
162 /// std::iota(ticks.begin(), ticks.end(), 1);
163 ///
164 /// rec.send_columns(
165 /// "box",
166 /// rerun::TimeColumn::from_sequence("tick", ticks),
167 /// rerun::Transform3D()
168 /// .with_many_translation(translations)
169 /// .with_many_rotation_axis_angle(rotations)
170 /// .columns()
171 /// );
172 /// }
173 /// ```
174 ///
175 /// ### Update specific properties of a transform over time
176 /// ![image](https://static.rerun.io/transform3d_partial_updates/11815bebc69ae400847896372b496cdd3e9b19fb/full.png)
177 ///
178 /// ```cpp
179 /// #include <rerun.hpp>
180 ///
181 /// float truncated_radians(int deg) {
182 /// auto degf = static_cast<float>(deg);
183 /// const auto pi = 3.14159265358979323846f;
184 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) /
185 /// 1000.0f;
186 /// }
187 ///
188 /// int main(int argc, char* argv[]) {
189 /// const auto rec =
190 /// rerun::RecordingStream("rerun_example_transform3d_partial_updates");
191 /// rec.spawn().exit_on_failure();
192 ///
193 /// // Set up a 3D box.
194 /// rec.log(
195 /// "box",
196 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}})
197 /// .with_fill_mode(rerun::FillMode::Solid)
198 /// );
199 ///
200 /// // Update only the rotation of the box.
201 /// for (int deg = 0; deg <= 45; deg++) {
202 /// auto rad = truncated_radians(deg * 4);
203 /// rec.log(
204 /// "box",
205 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle(
206 /// {0.0f, 1.0f, 0.0f},
207 /// rerun::Angle::radians(rad)
208 /// ))
209 /// );
210 /// }
211 ///
212 /// // Update only the position of the box.
213 /// for (int t = 0; t <= 50; t++) {
214 /// rec.log(
215 /// "box",
216 /// rerun::Transform3D::from_translation(
217 /// {0.0f, 0.0f, static_cast<float>(t) / 10.0f}
218 /// )
219 /// );
220 /// }
221 ///
222 /// // Update only the rotation of the box.
223 /// for (int deg = 0; deg <= 45; deg++) {
224 /// auto rad = truncated_radians((deg + 45) * 4);
225 /// rec.log(
226 /// "box",
227 /// rerun::Transform3D::from_rotation(rerun::RotationAxisAngle(
228 /// {0.0f, 1.0f, 0.0f},
229 /// rerun::Angle::radians(rad)
230 /// ))
231 /// );
232 /// }
233 ///
234 /// // Clear all of the box's attributes.
235 /// rec.log("box", rerun::Transform3D::clear_fields());
236 /// }
237 /// ```
238 struct Transform3D {
239 /// Translation vector.
240 ///
241 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
242 std::optional<ComponentBatch> translation;
243
244 /// Rotation via axis + angle.
245 ///
246 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
247 std::optional<ComponentBatch> rotation_axis_angle;
248
249 /// Rotation via quaternion.
250 ///
251 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
252 std::optional<ComponentBatch> quaternion;
253
254 /// Scaling factor.
255 ///
256 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
257 std::optional<ComponentBatch> scale;
258
259 /// 3x3 transformation matrix.
260 ///
261 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
262 std::optional<ComponentBatch> mat3x3;
263
264 /// Specifies the relation this transform establishes between this entity and its parent.
265 ///
266 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
267 std::optional<ComponentBatch> relation;
268
269 /// The child frame this transform transforms from.
270 ///
271 /// The entity at which the transform relationship of any given child frame is specified mustn't change over time, but is allowed to be different for static time.
272 /// E.g. if you specified the child frame `"robot_arm"` on an entity named `"my_transforms"`, you may not log transforms
273 /// with the child frame `"robot_arm"` on any other entity than `"my_transforms"` unless one of them was logged with static time.
274 ///
275 /// If not specified, this is set to the implicit transform frame of the current entity path.
276 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity/path`.
277 ///
278 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
279 ///
280 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
281 std::optional<ComponentBatch> child_frame;
282
283 /// The parent frame this transform transforms into.
284 ///
285 /// Any child frame has exactly one parent frame at any point in time, so logging a different `parent_frame` for a known `child_frame` replaces the previous relationship.
286 ///
287 /// If not specified, this is set to the implicit transform frame of the current entity path's parent.
288 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity`.
289 ///
290 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
291 ///
292 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
293 std::optional<ComponentBatch> parent_frame;
294
295 public:
296 /// The name of the archetype as used in `ComponentDescriptor`s.
297 static constexpr const char ArchetypeName[] = "rerun.archetypes.Transform3D";
298
299 /// `ComponentDescriptor` for the `translation` field.
301 ArchetypeName, "Transform3D:translation",
303 );
304 /// `ComponentDescriptor` for the `rotation_axis_angle` field.
306 ArchetypeName, "Transform3D:rotation_axis_angle",
308 );
309 /// `ComponentDescriptor` for the `quaternion` field.
311 ArchetypeName, "Transform3D:quaternion",
313 );
314 /// `ComponentDescriptor` for the `scale` field.
315 static constexpr auto Descriptor_scale = ComponentDescriptor(
317 );
318 /// `ComponentDescriptor` for the `mat3x3` field.
319 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
320 ArchetypeName, "Transform3D:mat3x3",
322 );
323 /// `ComponentDescriptor` for the `relation` field.
325 ArchetypeName, "Transform3D:relation",
327 );
328 /// `ComponentDescriptor` for the `child_frame` field.
330 ArchetypeName, "Transform3D:child_frame",
332 );
333 /// `ComponentDescriptor` for the `parent_frame` field.
335 ArchetypeName, "Transform3D:parent_frame",
337 );
338
339 public: // START of extensions from transform3d_ext.cpp:
340 /// Identity transformation.
341 ///
342 /// Applying this transform does not alter an entity's transformation.
343 RERUN_SDK_EXPORT static const Transform3D IDENTITY;
344
345 /// Invalid transformation.
346 ///
347 /// Applying this transform will cause this entity and the entire subtree not to be visualized.
348 RERUN_SDK_EXPORT static const Transform3D INVALID;
349
350 /// Creates a new 3D transform from translation and matrix provided as 3 columns.
351 /// Clears out all other components like `Transform3D::clear_fields`.
352 ///
353 /// \param translation_ \çopydoc Transform3D::translation
354 /// \param columns Column vectors of 3x3 matrix.
355 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
356 ///
357 /// _Implementation note:_ This overload is necessary, otherwise the array may be
358 /// interpreted as bool and call the wrong overload.
360 const components::Translation3D& translation_, const encodings::Vec3D (&columns)[3],
361 bool from_parent = false
362 )
363 : Transform3D(translation_, components::TransformMat3x3(columns), from_parent) {}
364
365 /// Creates a new 3D transform from translation/matrix.
366 /// Clears out all other components like `Transform3D::clear_fields`.
367 ///
368 /// \param translation_ \çopydoc Transform3D::translation
369 /// \param mat3x3_ \copydoc Transform3D::mat3x3
370 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
372 const components::Translation3D& translation_,
373 const components::TransformMat3x3& mat3x3_, bool from_parent = false
374 ) {
375 *this = Transform3D().with_translation(translation_).with_mat3x3(mat3x3_);
376 if (from_parent) {
377 *this =
379 }
380 }
381
382 /// From a translation applied after a 3x3 matrix.
383 /// Clears out all other components like `Transform3D::clear_fields`.
384 ///
385 /// \param translation \çopydoc Transform3D::translation
386 /// \param mat3x3 \copydoc Transform3D::mat3x3
389 ) {
390 return Transform3D(translation, mat3x3, false);
391 }
392
393 /// From a translation applied after a 3x3 matrix provided as 3 columns.
394 /// Clears out all other components like `Transform3D::clear_fields`.
395 ///
396 /// \param translation \çopydoc Transform3D::translation
397 /// \param columns Column vectors of 3x3 matrix.
400 ) {
404 );
405 }
406
407 /// From translation only.
408 /// Clears out all other components like `Transform3D::clear_fields`.
409 ///
410 /// \param translation_ \çopydoc Transform3D::translation
411 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
412 Transform3D(const components::Translation3D& translation_, bool from_parent = false) {
413 *this = Transform3D().with_translation(translation_);
414 if (from_parent) {
415 *this =
417 }
418 }
419
420 /// From a translation.
421 /// Clears out all other components like `Transform3D::clear_fields`.
422 ///
423 /// \param translation \çopydoc Transform3D::translation
425 return Transform3D(translation, false);
426 }
427
428 /// From 3x3 matrix only.
429 /// Clears out all other components like `Transform3D::clear_fields`.
430 ///
431 /// \param mat3x3_ \copydoc Transform3D::mat3x3
432 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
433 Transform3D(const components::TransformMat3x3& mat3x3_, bool from_parent = false) {
434 *this = Transform3D().with_mat3x3(mat3x3_);
435 if (from_parent) {
436 *this =
438 }
439 }
440
441 /// From 3x3 matrix only.
442 /// Clears out all other components like `Transform3D::clear_fields`.
443 ///
444 /// \param mat3x3 \copydoc Transform3D::mat3x3
446 return Transform3D(mat3x3, false);
447 }
448
449 /// From 3x3 matrix provided as 3 columns only.
450 /// Clears out all other components like `Transform3D::clear_fields`.
451 ///
452 /// \param columns Column vectors of 3x3 matrix.
453 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
454 Transform3D(const encodings::Vec3D (&columns)[3], bool from_parent = false)
455 : Transform3D(components::TransformMat3x3(columns), from_parent) {}
456
457 /// From 3x3 matrix provided as 3 columns only.
458 /// Clears out all other components like `Transform3D::clear_fields`.
459 ///
460 /// \param columns Column vectors of 3x3 matrix.
463 }
464
465 /// Creates a new 3D transform from translation/rotation/scale.
466 /// Clears out all other components like `Transform3D::clear_fields`.
467 ///
468 /// \param translation_ \copydoc Transform3D::translation
469 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
470 /// \param scale_ \copydoc Transform3D::scale
471 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
473 const components::Translation3D& translation_, const Rotation3D& rotation,
474 const components::Scale3D& scale_, bool from_parent = false
475 ) {
476 *this = Transform3D()
477 .with_translation(translation_)
478 .with_scale(scale_)
479 .with_rotation(rotation);
480 if (from_parent) {
481 *this =
483 }
484 }
485
486 /// Creates a new 3D transform from translation/rotation/uniform-scale.
487 /// Clears out all other components like `Transform3D::clear_fields`.
488 ///
489 /// \param translation_ \copydoc Transform3D::translation
490 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
491 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
492 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
493 ///
494 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
495 /// bool, leading to a call to the wrong overload.
497 const components::Translation3D& translation_, const Rotation3D& rotation,
498 float uniform_scale, bool from_parent = false
499 )
500 : Transform3D(translation_, rotation, components::Scale3D(uniform_scale), from_parent) {
501 }
502
503 /// From a translation, applied after a rotation & scale, known as an affine transformation.
504 /// Clears out all other components like `Transform3D::clear_fields`.
505 ///
506 /// \param translation \copydoc Transform3D::translation
507 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
508 /// \param scale \copydoc Transform3D::scale
510 const components::Translation3D& translation, const Rotation3D& rotation,
512 ) {
513 return Transform3D(translation, rotation, scale, false);
514 }
515
516 /// From a translation, applied after a rotation & scale, known as an affine transformation.
517 /// Clears out all other components like `Transform3D::clear_fields`.
518 ///
519 /// \param translation \copydoc Transform3D::translation
520 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
521 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
523 const components::Translation3D& translation, const Rotation3D& rotation,
524 float uniform_scale
525 ) {
526 return Transform3D(translation, rotation, components::Scale3D(uniform_scale), false);
527 }
528
529 /// Creates a new rigid transform (translation & rotation only).
530 /// Clears out all other components like `Transform3D::clear_fields`.
531 ///
532 /// \param translation_ \copydoc Transform3D::translation
533 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
534 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
536 const components::Translation3D& translation_, const Rotation3D& rotation,
537 bool from_parent = false
538 ) {
539 *this = Transform3D().with_translation(translation_).with_rotation(rotation);
540 if (from_parent) {
541 *this =
543 }
544 }
545
546 /// From a rotation & scale.
547 /// Clears out all other components like `Transform3D::clear_fields`.
548 ///
549 /// \param translation \copydoc Transform3D::translation
550 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
552 const components::Translation3D& translation, const Rotation3D& rotation
553 ) {
554 return Transform3D(translation, rotation, false);
555 }
556
557 /// From translation & scale only.
558 /// Clears out all other components like `Transform3D::clear_fields`.
559 ///
560 /// \param translation_ \copydoc Transform3D::translation
561 /// \param scale_ Transform3D::scale
562 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
564 const components::Translation3D& translation_, const components::Scale3D& scale_,
565 bool from_parent = false
566 ) {
567 *this = Transform3D().with_translation(translation_).with_scale(scale_);
568 if (from_parent) {
569 *this =
571 }
572 }
573
574 /// From a translation applied after a scale.
575 /// Clears out all other components like `Transform3D::clear_fields`.
576 ///
577 /// \param translation \copydoc Transform3D::translation
578 /// \param scale Transform3D::scale
581 ) {
582 return Transform3D(translation, scale, false);
583 }
584
585 /// From translation & uniform scale only.
586 /// Clears out all other components like `Transform3D::clear_fields`.
587 ///
588 /// \param translation_ \copydoc Transform3D::translation
589 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
590 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
591 ///
592 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
593 /// bool, leading to a call to the wrong overload.
595 const components::Translation3D& translation_, float uniform_scale,
596 bool from_parent = false
597 )
598 : Transform3D(translation_, components::Scale3D(uniform_scale), from_parent) {}
599
600 /// From rotation & scale.
601 /// Clears out all other components like `Transform3D::clear_fields`.
602 ///
603 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
604 /// \param scale_ Transform3D::scale
605 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
607 const Rotation3D& rotation, const components::Scale3D& scale_, bool from_parent = false
608 ) {
609 *this = Transform3D().with_scale(scale_).with_rotation(rotation);
610 if (from_parent) {
611 *this =
613 }
614 }
615
616 /// From rotation & uniform scale.
617 /// Clears out all other components like `Transform3D::clear_fields`.
618 ///
619 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
620 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
621 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
622 ///
623 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
624 /// bool, leading to a call to the wrong overload.
625 Transform3D(const Rotation3D& rotation, float uniform_scale, bool from_parent = false)
626 : Transform3D(rotation, components::Scale3D(uniform_scale), from_parent) {}
627
628 /// From a rotation & scale.
629 /// Clears out all other components like `Transform3D::clear_fields`.
630 ///
631 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
632 /// \param scale Transform3D::scale
634 const Rotation3D& rotation, const components::Scale3D& scale
635 ) {
636 return Transform3D(rotation, scale, false);
637 }
638
639 /// From a rotation & uniform scale.
640 /// Clears out all other components like `Transform3D::clear_fields`.
641 ///
642 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
643 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
644 static Transform3D from_rotation_scale(const Rotation3D& rotation, float uniform_scale) {
645 return Transform3D(rotation, components::Scale3D(uniform_scale), false);
646 }
647
648 /// From rotation only.
649 /// Clears out all other components like `Transform3D::clear_fields`.
650 ///
651 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
652 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
653 Transform3D(const Rotation3D& rotation, bool from_parent = false) {
654 *this = Transform3D().with_rotation(rotation);
655 if (from_parent) {
656 *this =
658 }
659 }
660
661 /// From rotation only.
662 /// Clears out all other components like `Transform3D::clear_fields`.
663 ///
664 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
665 static Transform3D from_rotation(const Rotation3D& rotation) {
666 return Transform3D(rotation, false);
667 }
668
669 /// From scale only.
670 /// Clears out all other components like `Transform3D::clear_fields`.
671 ///
672 /// \param scale_ If true, the transform relation to `TransformRelation::ChildFromParent`.
673 /// \param from_parent \copydoc Transform3D::scale
674 Transform3D(const components::Scale3D& scale_, bool from_parent = false) {
675 *this = Transform3D().with_scale(scale_);
676 if (from_parent) {
677 *this =
679 }
680 }
681
682 /// From scale only.
683 /// Clears out all other components like `Transform3D::clear_fields`.
684 ///
685 /// \param scale Transform3D::scale
687 return Transform3D(scale, false);
688 }
689
690 /// From scale only.
691 /// Clears out all other components like `Transform3D::clear_fields`.
692 ///
693 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
694 static Transform3D from_scale(float uniform_scale) {
695 return Transform3D(components::Scale3D(uniform_scale), false);
696 }
697
698 /// Set the rotation component of the transform using the `rerun::Rotation3D` utility.
700 if (rotation.axis_angle.has_value()) {
701 *this = std::move(*this).with_rotation_axis_angle(rotation.axis_angle.value());
702 }
703 if (rotation.quaternion.has_value()) {
704 *this = std::move(*this).with_quaternion(rotation.quaternion.value());
705 }
706 return std::move(*this);
707 }
708
709 // END of extensions from transform3d_ext.cpp, start of generated code:
710
711 public:
712 Transform3D() = default;
713 Transform3D(Transform3D&& other) = default;
714 Transform3D(const Transform3D& other) = default;
715 Transform3D& operator=(const Transform3D& other) = default;
716 Transform3D& operator=(Transform3D&& other) = default;
717
718 /// Update only some specific fields of a `Transform3D`.
720 return Transform3D();
721 }
722
723 /// Clear all the fields of a `Transform3D`.
725
726 /// Translation vector.
727 ///
728 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
731 .value_or_throw();
732 return std::move(*this);
733 }
734
735 /// This method makes it possible to pack multiple `translation` in a single component batch.
736 ///
737 /// This only makes sense when used in conjunction with `columns`. `with_translation` should
738 /// be used when logging a single row's worth of data.
741 ) && {
743 .value_or_throw();
744 return std::move(*this);
745 }
746
747 /// Rotation via axis + angle.
748 ///
749 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
751 const rerun::components::RotationAxisAngle& _rotation_axis_angle
752 ) && {
755 .value_or_throw();
756 return std::move(*this);
757 }
758
759 /// This method makes it possible to pack multiple `rotation_axis_angle` in a single component batch.
760 ///
761 /// This only makes sense when used in conjunction with `columns`. `with_rotation_axis_angle` should
762 /// be used when logging a single row's worth of data.
764 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angle
765 ) && {
768 .value_or_throw();
769 return std::move(*this);
770 }
771
772 /// Rotation via quaternion.
773 ///
774 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
776 quaternion =
777 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
778 return std::move(*this);
779 }
780
781 /// This method makes it possible to pack multiple `quaternion` in a single component batch.
782 ///
783 /// This only makes sense when used in conjunction with `columns`. `with_quaternion` should
784 /// be used when logging a single row's worth of data.
787 ) && {
788 quaternion =
789 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
790 return std::move(*this);
791 }
792
793 /// Scaling factor.
794 ///
795 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
797 scale = ComponentBatch::from_loggable(_scale, Descriptor_scale).value_or_throw();
798 return std::move(*this);
799 }
800
801 /// This method makes it possible to pack multiple `scale` in a single component batch.
802 ///
803 /// This only makes sense when used in conjunction with `columns`. `with_scale` should
804 /// be used when logging a single row's worth of data.
806 scale = ComponentBatch::from_loggable(_scale, Descriptor_scale).value_or_throw();
807 return std::move(*this);
808 }
809
810 /// 3x3 transformation matrix.
811 ///
812 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
814 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
815 return std::move(*this);
816 }
817
818 /// This method makes it possible to pack multiple `mat3x3` in a single component batch.
819 ///
820 /// This only makes sense when used in conjunction with `columns`. `with_mat3x3` should
821 /// be used when logging a single row's worth of data.
823 ) && {
824 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
825 return std::move(*this);
826 }
827
828 /// Specifies the relation this transform establishes between this entity and its parent.
829 ///
830 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
832 relation =
833 ComponentBatch::from_loggable(_relation, Descriptor_relation).value_or_throw();
834 return std::move(*this);
835 }
836
837 /// This method makes it possible to pack multiple `relation` in a single component batch.
838 ///
839 /// This only makes sense when used in conjunction with `columns`. `with_relation` should
840 /// be used when logging a single row's worth of data.
843 ) && {
844 relation =
845 ComponentBatch::from_loggable(_relation, Descriptor_relation).value_or_throw();
846 return std::move(*this);
847 }
848
849 /// The child frame this transform transforms from.
850 ///
851 /// The entity at which the transform relationship of any given child frame is specified mustn't change over time, but is allowed to be different for static time.
852 /// E.g. if you specified the child frame `"robot_arm"` on an entity named `"my_transforms"`, you may not log transforms
853 /// with the child frame `"robot_arm"` on any other entity than `"my_transforms"` unless one of them was logged with static time.
854 ///
855 /// If not specified, this is set to the implicit transform frame of the current entity path.
856 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity/path`.
857 ///
858 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
859 ///
860 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
863 .value_or_throw();
864 return std::move(*this);
865 }
866
867 /// This method makes it possible to pack multiple `child_frame` in a single component batch.
868 ///
869 /// This only makes sense when used in conjunction with `columns`. `with_child_frame` should
870 /// be used when logging a single row's worth of data.
873 ) && {
875 .value_or_throw();
876 return std::move(*this);
877 }
878
879 /// The parent frame this transform transforms into.
880 ///
881 /// Any child frame has exactly one parent frame at any point in time, so logging a different `parent_frame` for a known `child_frame` replaces the previous relationship.
882 ///
883 /// If not specified, this is set to the implicit transform frame of the current entity path's parent.
884 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity`.
885 ///
886 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
887 ///
888 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
891 .value_or_throw();
892 return std::move(*this);
893 }
894
895 /// This method makes it possible to pack multiple `parent_frame` in a single component batch.
896 ///
897 /// This only makes sense when used in conjunction with `columns`. `with_parent_frame` should
898 /// be used when logging a single row's worth of data.
901 ) && {
903 .value_or_throw();
904 return std::move(*this);
905 }
906
907 /// Partitions the component data into multiple sub-batches.
908 ///
909 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
910 /// instead, via `ComponentBatch::partitioned`.
911 ///
912 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
913 ///
914 /// The specified `lengths` must sum to the total length of the component batch.
916
917 /// Partitions the component data into unit-length sub-batches.
918 ///
919 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
920 /// where `n` is automatically guessed.
922 };
923
924} // namespace rerun::archetypes
925
926namespace rerun {
927 /// \private
928 template <typename T>
929 struct AsComponents;
930
931 /// \private
932 template <>
933 struct AsComponents<archetypes::Transform3D> {
934 /// Serialize all set component batches.
935 static Result<Collection<ComponentBatch>> as_batches(
936 const archetypes::Transform3D& archetype
937 );
938 };
939} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
TransformRelation
Component: Specifies relation a spatial transform describes.
Definition transform_relation.hpp:24
@ ChildFromParent
The transform describes how to transform into the child entity's space.
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Utility for representing a single 3D rotation, agnostic to the underlying representation.
Definition rotation3d.hpp:14
Archetype: A transform between two 3D spaces, i.e.
Definition transform3d.hpp:238
static constexpr auto Descriptor_rotation_axis_angle
ComponentDescriptor for the rotation_axis_angle field.
Definition transform3d.hpp:305
static RERUN_SDK_EXPORT const Transform3D IDENTITY
Identity transformation.
Definition transform3d.hpp:343
Transform3D(const encodings::Vec3D(&columns)[3], bool from_parent=false)
From 3x3 matrix provided as 3 columns only.
Definition transform3d.hpp:454
std::optional< ComponentBatch > parent_frame
The parent frame this transform transforms into.
Definition transform3d.hpp:293
std::optional< ComponentBatch > mat3x3
3x3 transformation matrix.
Definition transform3d.hpp:262
Transform3D(const components::Translation3D &translation_, const components::TransformMat3x3 &mat3x3_, bool from_parent=false)
Creates a new 3D transform from translation/matrix.
Definition transform3d.hpp:371
std::optional< ComponentBatch > child_frame
The child frame this transform transforms from.
Definition transform3d.hpp:281
static Transform3D from_translation_scale(const components::Translation3D &translation, const components::Scale3D &scale)
From a translation applied after a scale.
Definition transform3d.hpp:579
Transform3D with_relation(const rerun::components::TransformRelation &_relation) &&
Specifies the relation this transform establishes between this entity and its parent.
Definition transform3d.hpp:831
Transform3D(const components::Translation3D &translation_, const Rotation3D &rotation, float uniform_scale, bool from_parent=false)
Creates a new 3D transform from translation/rotation/uniform-scale.
Definition transform3d.hpp:496
static Transform3D from_mat3x3(const components::TransformMat3x3 &mat3x3)
From 3x3 matrix only.
Definition transform3d.hpp:445
Transform3D(const components::Translation3D &translation_, const Rotation3D &rotation, const components::Scale3D &scale_, bool from_parent=false)
Creates a new 3D transform from translation/rotation/scale.
Definition transform3d.hpp:472
Transform3D(const Rotation3D &rotation, float uniform_scale, bool from_parent=false)
From rotation & uniform scale.
Definition transform3d.hpp:625
Transform3D(const components::Translation3D &translation_, float uniform_scale, bool from_parent=false)
From translation & uniform scale only.
Definition transform3d.hpp:594
Transform3D with_scale(const rerun::components::Scale3D &_scale) &&
Scaling factor.
Definition transform3d.hpp:796
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_child_frame
ComponentDescriptor for the child_frame field.
Definition transform3d.hpp:329
static RERUN_SDK_EXPORT const Transform3D INVALID
Invalid transformation.
Definition transform3d.hpp:348
Transform3D with_many_child_frame(const Collection< rerun::components::TransformFrameId > &_child_frame) &&
This method makes it possible to pack multiple child_frame in a single component batch.
Definition transform3d.hpp:871
Transform3D with_quaternion(const rerun::components::RotationQuat &_quaternion) &&
Rotation via quaternion.
Definition transform3d.hpp:775
std::optional< ComponentBatch > translation
Translation vector.
Definition transform3d.hpp:242
Transform3D(const components::Translation3D &translation_, const Rotation3D &rotation, bool from_parent=false)
Creates a new rigid transform (translation & rotation only).
Definition transform3d.hpp:535
Transform3D with_translation(const rerun::components::Translation3D &_translation) &&
Translation vector.
Definition transform3d.hpp:729
Transform3D(const Rotation3D &rotation, bool from_parent=false)
From rotation only.
Definition transform3d.hpp:653
Transform3D(const components::TransformMat3x3 &mat3x3_, bool from_parent=false)
From 3x3 matrix only.
Definition transform3d.hpp:433
static Transform3D update_fields()
Update only some specific fields of a Transform3D.
Definition transform3d.hpp:719
static Transform3D from_rotation_scale(const Rotation3D &rotation, float uniform_scale)
From a rotation & uniform scale.
Definition transform3d.hpp:644
static Transform3D from_translation_mat3x3(const components::Translation3D &translation, const components::TransformMat3x3 &mat3x3)
From a translation applied after a 3x3 matrix.
Definition transform3d.hpp:387
static Transform3D from_rotation_scale(const Rotation3D &rotation, const components::Scale3D &scale)
From a rotation & scale.
Definition transform3d.hpp:633
static Transform3D from_translation(const components::Translation3D &translation)
From a translation.
Definition transform3d.hpp:424
Transform3D with_rotation(const Rotation3D &rotation) &&
Set the rotation component of the transform using the rerun::Rotation3D utility.
Definition transform3d.hpp:699
static Transform3D from_scale(float uniform_scale)
From scale only.
Definition transform3d.hpp:694
std::optional< ComponentBatch > rotation_axis_angle
Rotation via axis + angle.
Definition transform3d.hpp:247
Transform3D with_many_mat3x3(const Collection< rerun::components::TransformMat3x3 > &_mat3x3) &&
This method makes it possible to pack multiple mat3x3 in a single component batch.
Definition transform3d.hpp:822
static constexpr auto Descriptor_translation
ComponentDescriptor for the translation field.
Definition transform3d.hpp:300
Transform3D with_many_rotation_axis_angle(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angle) &&
This method makes it possible to pack multiple rotation_axis_angle in a single component batch.
Definition transform3d.hpp:763
static constexpr auto Descriptor_quaternion
ComponentDescriptor for the quaternion field.
Definition transform3d.hpp:310
static Transform3D from_translation_rotation_scale(const components::Translation3D &translation, const Rotation3D &rotation, const components::Scale3D &scale)
From a translation, applied after a rotation & scale, known as an affine transformation.
Definition transform3d.hpp:509
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition transform3d.hpp:297
static Transform3D from_mat3x3(const encodings::Vec3D(&columns)[3])
From 3x3 matrix provided as 3 columns only.
Definition transform3d.hpp:461
static constexpr auto Descriptor_parent_frame
ComponentDescriptor for the parent_frame field.
Definition transform3d.hpp:334
static constexpr auto Descriptor_scale
ComponentDescriptor for the scale field.
Definition transform3d.hpp:315
Transform3D(const components::Scale3D &scale_, bool from_parent=false)
From scale only.
Definition transform3d.hpp:674
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition transform3d.hpp:319
static Transform3D from_translation_rotation(const components::Translation3D &translation, const Rotation3D &rotation)
From a rotation & scale.
Definition transform3d.hpp:551
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > quaternion
Rotation via quaternion.
Definition transform3d.hpp:252
Transform3D with_child_frame(const rerun::components::TransformFrameId &_child_frame) &&
The child frame this transform transforms from.
Definition transform3d.hpp:861
Transform3D(const Rotation3D &rotation, const components::Scale3D &scale_, bool from_parent=false)
From rotation & scale.
Definition transform3d.hpp:606
Transform3D with_many_relation(const Collection< rerun::components::TransformRelation > &_relation) &&
This method makes it possible to pack multiple relation in a single component batch.
Definition transform3d.hpp:841
Transform3D(const components::Translation3D &translation_, bool from_parent=false)
From translation only.
Definition transform3d.hpp:412
Transform3D with_many_quaternion(const Collection< rerun::components::RotationQuat > &_quaternion) &&
This method makes it possible to pack multiple quaternion in a single component batch.
Definition transform3d.hpp:785
Transform3D with_rotation_axis_angle(const rerun::components::RotationAxisAngle &_rotation_axis_angle) &&
Rotation via axis + angle.
Definition transform3d.hpp:750
static Transform3D from_translation_mat3x3(const components::Translation3D &translation, const encodings::Vec3D(&columns)[3])
From a translation applied after a 3x3 matrix provided as 3 columns.
Definition transform3d.hpp:398
Transform3D with_parent_frame(const rerun::components::TransformFrameId &_parent_frame) &&
The parent frame this transform transforms into.
Definition transform3d.hpp:889
Transform3D with_many_translation(const Collection< rerun::components::Translation3D > &_translation) &&
This method makes it possible to pack multiple translation in a single component batch.
Definition transform3d.hpp:739
Transform3D(const components::Translation3D &translation_, const components::Scale3D &scale_, bool from_parent=false)
From translation & scale only.
Definition transform3d.hpp:563
std::optional< ComponentBatch > relation
Specifies the relation this transform establishes between this entity and its parent.
Definition transform3d.hpp:267
static Transform3D clear_fields()
Clear all the fields of a Transform3D.
Transform3D with_many_scale(const Collection< rerun::components::Scale3D > &_scale) &&
This method makes it possible to pack multiple scale in a single component batch.
Definition transform3d.hpp:805
Transform3D(const components::Translation3D &translation_, const encodings::Vec3D(&columns)[3], bool from_parent=false)
Creates a new 3D transform from translation and matrix provided as 3 columns.
Definition transform3d.hpp:359
static Transform3D from_translation_rotation_scale(const components::Translation3D &translation, const Rotation3D &rotation, float uniform_scale)
From a translation, applied after a rotation & scale, known as an affine transformation.
Definition transform3d.hpp:522
Transform3D with_mat3x3(const rerun::components::TransformMat3x3 &_mat3x3) &&
3x3 transformation matrix.
Definition transform3d.hpp:813
static constexpr auto Descriptor_relation
ComponentDescriptor for the relation field.
Definition transform3d.hpp:324
static Transform3D from_scale(const components::Scale3D &scale)
From scale only.
Definition transform3d.hpp:686
std::optional< ComponentBatch > scale
Scaling factor.
Definition transform3d.hpp:257
static Transform3D from_rotation(const Rotation3D &rotation)
From rotation only.
Definition transform3d.hpp:665
Transform3D with_many_parent_frame(const Collection< rerun::components::TransformFrameId > &_parent_frame) &&
This method makes it possible to pack multiple parent_frame in a single component batch.
Definition transform3d.hpp:899
Component: 3D rotation represented by a rotation around a given axis.
Definition rotation_axis_angle.hpp:17
Component: A 3D rotation expressed as a quaternion.
Definition rotation_quat.hpp:18
Component: A 3D scale factor.
Definition scale3d.hpp:19
Component: A string identifier for a transform frame.
Definition transform_frame_id.hpp:24
Component: A 3x3 transformation matrix Matrix.
Definition transform_mat3x3.hpp:27
Component: A translation vector in 3D space.
Definition translation3d.hpp:15
Encoding: A vector in 3D space.
Definition vec3d.hpp:20