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/store/re_sdk_types/definitions/rerun/archetypes/transform3d.fbs".
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() {
52 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d");
53 /// rec.spawn().exit_on_failure();
54 ///
55 /// auto arrow =
56 /// rerun::Arrows3D::from_vectors({{0.0f, 1.0f, 0.0f}}).with_origins({{0.0f, 0.0f, 0.0f}});
57 ///
58 /// rec.log("base", arrow);
59 ///
60 /// rec.log("base/translated", rerun::Transform3D::from_translation({1.0f, 0.0f, 0.0f}));
61 /// rec.log("base/translated", arrow);
62 ///
63 /// rec.log(
64 /// "base/rotated_scaled",
65 /// rerun::Transform3D::from_rotation_scale(
66 /// rerun::RotationAxisAngle({0.0f, 0.0f, 1.0f}, rerun::Angle::radians(TAU / 8.0f)),
67 /// 2.0f
68 /// )
69 /// );
70 /// rec.log("base/rotated_scaled", arrow);
71 /// }
72 /// ```
73 ///
74 /// ### Update a transform over time
75 /// ![image](https://static.rerun.io/transform3d_column_updates/80634e1c7c7a505387e975f25ea8b6bc1d4eb9db/full.png)
76 ///
77 /// ```cpp
78 /// #include <rerun.hpp>
79 ///
80 /// float truncated_radians(int deg) {
81 /// auto degf = static_cast<float>(deg);
82 /// const auto pi = 3.14159265358979323846f;
83 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) / 1000.0f;
84 /// }
85 ///
86 /// int main() {
87 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d_row_updates");
88 /// rec.spawn().exit_on_failure();
89 ///
90 /// rec.set_time_sequence("tick", 0);
91 /// rec.log(
92 /// "box",
93 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}}).with_fill_mode(rerun::FillMode::Solid),
94 /// rerun::TransformAxes3D(10.0)
95 /// );
96 ///
97 /// for (int t = 0; t <100; t++) {
98 /// rec.set_time_sequence("tick", t + 1);
99 /// rec.log(
100 /// "box",
101 /// rerun::Transform3D()
102 /// .with_translation({0.0f, 0.0f, static_cast<float>(t) / 10.0f})
103 /// .with_rotation_axis_angle(rerun::RotationAxisAngle(
104 /// {0.0f, 1.0f, 0.0f},
105 /// rerun::Angle::radians(truncated_radians(t * 4))
106 /// ))
107 /// );
108 /// }
109 /// }
110 /// ```
111 ///
112 /// ### Update a transform over time, in a single operation
113 /// ![image](https://static.rerun.io/transform3d_column_updates/80634e1c7c7a505387e975f25ea8b6bc1d4eb9db/full.png)
114 ///
115 /// ```cpp
116 /// #include <cmath>
117 /// #include <numeric>
118 /// #include <vector>
119 ///
120 /// #include <rerun.hpp>
121 ///
122 /// float truncated_radians(int deg) {
123 /// auto degf = static_cast<float>(deg);
124 /// const auto pi = 3.14159265358979323846f;
125 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) / 1000.0f;
126 /// }
127 ///
128 /// int main() {
129 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d_column_updates");
130 /// rec.spawn().exit_on_failure();
131 ///
132 /// rec.set_time_sequence("tick", 0);
133 /// rec.log(
134 /// "box",
135 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}}).with_fill_mode(rerun::FillMode::Solid),
136 /// rerun::TransformAxes3D(10.0)
137 /// );
138 ///
139 /// std::vector<std::array<float, 3>> translations;
140 /// std::vector<rerun::RotationAxisAngle> rotations;
141 /// for (int t = 0; t <100; t++) {
142 /// translations.push_back({0.0f, 0.0f, static_cast<float>(t) / 10.0f});
143 /// rotations.push_back(rerun::RotationAxisAngle(
144 /// {0.0f, 1.0f, 0.0f},
145 /// rerun::Angle::radians(truncated_radians(t * 4))
146 /// ));
147 /// }
148 ///
149 /// std::vector<int64_t> ticks(100);
150 /// std::iota(ticks.begin(), ticks.end(), 1);
151 ///
152 /// rec.send_columns(
153 /// "box",
154 /// rerun::TimeColumn::from_sequence("tick", ticks),
155 /// rerun::Transform3D()
156 /// .with_many_translation(translations)
157 /// .with_many_rotation_axis_angle(rotations)
158 /// .columns()
159 /// );
160 /// }
161 /// ```
162 ///
163 /// ### Update specific properties of a transform over time
164 /// ![image](https://static.rerun.io/transform3d_partial_updates/11815bebc69ae400847896372b496cdd3e9b19fb/full.png)
165 ///
166 /// ```cpp
167 /// #include <rerun.hpp>
168 ///
169 /// float truncated_radians(int deg) {
170 /// auto degf = static_cast<float>(deg);
171 /// const auto pi = 3.14159265358979323846f;
172 /// return static_cast<float>(static_cast<int>(degf * pi / 180.0f * 1000.0f)) / 1000.0f;
173 /// }
174 ///
175 /// int main() {
176 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d_partial_updates");
177 /// rec.spawn().exit_on_failure();
178 ///
179 /// // Set up a 3D box.
180 /// rec.log(
181 /// "box",
182 /// rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}}).with_fill_mode(rerun::FillMode::Solid)
183 /// );
184 ///
185 /// // Update only the rotation of the box.
186 /// for (int deg = 0; deg <= 45; deg++) {
187 /// auto rad = truncated_radians(deg * 4);
188 /// rec.log(
189 /// "box",
190 /// rerun::Transform3D::from_rotation(
191 /// rerun::RotationAxisAngle({0.0f, 1.0f, 0.0f}, rerun::Angle::radians(rad))
192 /// )
193 /// );
194 /// }
195 ///
196 /// // Update only the position of the box.
197 /// for (int t = 0; t <= 50; t++) {
198 /// rec.log(
199 /// "box",
200 /// rerun::Transform3D::from_translation({0.0f, 0.0f, static_cast<float>(t) / 10.0f})
201 /// );
202 /// }
203 ///
204 /// // Update only the rotation of the box.
205 /// for (int deg = 0; deg <= 45; deg++) {
206 /// auto rad = truncated_radians((deg + 45) * 4);
207 /// rec.log(
208 /// "box",
209 /// rerun::Transform3D::from_rotation(
210 /// rerun::RotationAxisAngle({0.0f, 1.0f, 0.0f}, rerun::Angle::radians(rad))
211 /// )
212 /// );
213 /// }
214 ///
215 /// // Clear all of the box's attributes.
216 /// rec.log("box", rerun::Transform3D::clear_fields());
217 /// }
218 /// ```
219 struct Transform3D {
220 /// Translation vector.
221 ///
222 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
223 std::optional<ComponentBatch> translation;
224
225 /// Rotation via axis + angle.
226 ///
227 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
228 std::optional<ComponentBatch> rotation_axis_angle;
229
230 /// Rotation via quaternion.
231 ///
232 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
233 std::optional<ComponentBatch> quaternion;
234
235 /// Scaling factor.
236 ///
237 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
238 std::optional<ComponentBatch> scale;
239
240 /// 3x3 transformation matrix.
241 ///
242 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
243 std::optional<ComponentBatch> mat3x3;
244
245 /// Specifies the relation this transform establishes between this entity and its parent.
246 ///
247 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
248 std::optional<ComponentBatch> relation;
249
250 /// The child frame this transform transforms from.
251 ///
252 /// 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.
253 /// E.g. if you specified the child frame `"robot_arm"` on an entity named `"my_transforms"`, you may not log transforms
254 /// with the child frame `"robot_arm"` on any other entity than `"my_transforms"` unless one of them was logged with static time.
255 ///
256 /// If not specified, this is set to the implicit transform frame of the current entity path.
257 /// 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`.
258 ///
259 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
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> child_frame;
263
264 /// The parent frame this transform transforms into.
265 ///
266 /// If not specified, this is set to the implicit transform frame of the current entity path's parent.
267 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity`.
268 ///
269 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
270 ///
271 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
272 std::optional<ComponentBatch> parent_frame;
273
274 public:
275 /// The name of the archetype as used in `ComponentDescriptor`s.
276 static constexpr const char ArchetypeName[] = "rerun.archetypes.Transform3D";
277
278 /// `ComponentDescriptor` for the `translation` field.
280 ArchetypeName, "Transform3D:translation",
282 );
283 /// `ComponentDescriptor` for the `rotation_axis_angle` field.
285 ArchetypeName, "Transform3D:rotation_axis_angle",
287 );
288 /// `ComponentDescriptor` for the `quaternion` field.
290 ArchetypeName, "Transform3D:quaternion",
292 );
293 /// `ComponentDescriptor` for the `scale` field.
294 static constexpr auto Descriptor_scale = ComponentDescriptor(
296 );
297 /// `ComponentDescriptor` for the `mat3x3` field.
298 static constexpr auto Descriptor_mat3x3 = ComponentDescriptor(
299 ArchetypeName, "Transform3D:mat3x3",
301 );
302 /// `ComponentDescriptor` for the `relation` field.
304 ArchetypeName, "Transform3D:relation",
306 );
307 /// `ComponentDescriptor` for the `child_frame` field.
309 ArchetypeName, "Transform3D:child_frame",
311 );
312 /// `ComponentDescriptor` for the `parent_frame` field.
314 ArchetypeName, "Transform3D:parent_frame",
316 );
317
318 public: // START of extensions from transform3d_ext.cpp:
319 /// Identity transformation.
320 ///
321 /// Applying this transform does not alter an entity's transformation.
322 RERUN_SDK_EXPORT static const Transform3D IDENTITY;
323
324 /// Invalid transformation.
325 ///
326 /// Applying this transform will cause this entity and the entire subtree not to be visualized.
327 RERUN_SDK_EXPORT static const Transform3D INVALID;
328
329 /// Creates a new 3D transform from translation and matrix provided as 3 columns.
330 /// Clears out all other components like `Transform3D::clear_fields`.
331 ///
332 /// \param translation_ \çopydoc Transform3D::translation
333 /// \param columns Column vectors of 3x3 matrix.
334 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
335 ///
336 /// _Implementation note:_ This overload is necessary, otherwise the array may be
337 /// interpreted as bool and call the wrong overload.
339 const components::Translation3D& translation_, const datatypes::Vec3D (&columns)[3],
340 bool from_parent = false
341 )
342 : Transform3D(translation_, components::TransformMat3x3(columns), from_parent) {}
343
344 /// Creates a new 3D transform from translation/matrix.
345 /// Clears out all other components like `Transform3D::clear_fields`.
346 ///
347 /// \param translation_ \çopydoc Transform3D::translation
348 /// \param mat3x3_ \copydoc Transform3D::mat3x3
349 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
351 const components::Translation3D& translation_,
352 const components::TransformMat3x3& mat3x3_, bool from_parent = false
353 ) {
354 *this = Transform3D().with_translation(translation_).with_mat3x3(mat3x3_);
355 if (from_parent) {
356 *this =
358 }
359 }
360
361 /// From a translation applied after a 3x3 matrix.
362 /// Clears out all other components like `Transform3D::clear_fields`.
363 ///
364 /// \param translation \çopydoc Transform3D::translation
365 /// \param mat3x3 \copydoc Transform3D::mat3x3
368 ) {
369 return Transform3D(translation, mat3x3, false);
370 }
371
372 /// From a translation applied after a 3x3 matrix provided as 3 columns.
373 /// Clears out all other components like `Transform3D::clear_fields`.
374 ///
375 /// \param translation \çopydoc Transform3D::translation
376 /// \param columns Column vectors of 3x3 matrix.
379 ) {
383 );
384 }
385
386 /// From translation only.
387 /// Clears out all other components like `Transform3D::clear_fields`.
388 ///
389 /// \param translation_ \çopydoc Transform3D::translation
390 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
391 Transform3D(const components::Translation3D& translation_, bool from_parent = false) {
392 *this = Transform3D().with_translation(translation_);
393 if (from_parent) {
394 *this =
396 }
397 }
398
399 /// From a translation.
400 /// Clears out all other components like `Transform3D::clear_fields`.
401 ///
402 /// \param translation \çopydoc Transform3D::translation
404 return Transform3D(translation, false);
405 }
406
407 /// From 3x3 matrix only.
408 /// Clears out all other components like `Transform3D::clear_fields`.
409 ///
410 /// \param mat3x3_ \copydoc Transform3D::mat3x3
411 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
412 Transform3D(const components::TransformMat3x3& mat3x3_, bool from_parent = false) {
413 *this = Transform3D().with_mat3x3(mat3x3_);
414 if (from_parent) {
415 *this =
417 }
418 }
419
420 /// From 3x3 matrix only.
421 /// Clears out all other components like `Transform3D::clear_fields`.
422 ///
423 /// \param mat3x3 \copydoc Transform3D::mat3x3
425 return Transform3D(mat3x3, false);
426 }
427
428 /// From 3x3 matrix provided as 3 columns only.
429 /// Clears out all other components like `Transform3D::clear_fields`.
430 ///
431 /// \param columns Column vectors of 3x3 matrix.
432 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
433 Transform3D(const datatypes::Vec3D (&columns)[3], bool from_parent = false)
434 : Transform3D(components::TransformMat3x3(columns), from_parent) {}
435
436 /// From 3x3 matrix provided as 3 columns only.
437 /// Clears out all other components like `Transform3D::clear_fields`.
438 ///
439 /// \param columns Column vectors of 3x3 matrix.
442 }
443
444 /// Creates a new 3D transform from translation/rotation/scale.
445 /// Clears out all other components like `Transform3D::clear_fields`.
446 ///
447 /// \param translation_ \copydoc Transform3D::translation
448 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
449 /// \param scale_ \copydoc Transform3D::scale
450 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
452 const components::Translation3D& translation_, const Rotation3D& rotation,
453 const components::Scale3D& scale_, bool from_parent = false
454 ) {
455 *this = Transform3D()
456 .with_translation(translation_)
457 .with_scale(scale_)
458 .with_rotation(rotation);
459 if (from_parent) {
460 *this =
462 }
463 }
464
465 /// Creates a new 3D transform from translation/rotation/uniform-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 uniform_scale Uniform scale factor that is applied to all axis equally.
471 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
472 ///
473 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
474 /// bool, leading to a call to the wrong overload.
476 const components::Translation3D& translation_, const Rotation3D& rotation,
477 float uniform_scale, bool from_parent = false
478 )
479 : Transform3D(translation_, rotation, components::Scale3D(uniform_scale), from_parent) {
480 }
481
482 /// From a translation, applied after a rotation & scale, known as an affine transformation.
483 /// Clears out all other components like `Transform3D::clear_fields`.
484 ///
485 /// \param translation \copydoc Transform3D::translation
486 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
487 /// \param scale \copydoc Transform3D::scale
489 const components::Translation3D& translation, const Rotation3D& rotation,
491 ) {
492 return Transform3D(translation, rotation, scale, false);
493 }
494
495 /// From a translation, applied after a rotation & scale, known as an affine transformation.
496 /// Clears out all other components like `Transform3D::clear_fields`.
497 ///
498 /// \param translation \copydoc Transform3D::translation
499 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
500 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
502 const components::Translation3D& translation, const Rotation3D& rotation,
503 float uniform_scale
504 ) {
505 return Transform3D(translation, rotation, components::Scale3D(uniform_scale), false);
506 }
507
508 /// Creates a new rigid transform (translation & rotation only).
509 /// Clears out all other components like `Transform3D::clear_fields`.
510 ///
511 /// \param translation_ \copydoc Transform3D::translation
512 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
513 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
515 const components::Translation3D& translation_, const Rotation3D& rotation,
516 bool from_parent = false
517 ) {
518 *this = Transform3D().with_translation(translation_).with_rotation(rotation);
519 if (from_parent) {
520 *this =
522 }
523 }
524
525 /// From a rotation & scale.
526 /// Clears out all other components like `Transform3D::clear_fields`.
527 ///
528 /// \param translation \copydoc Transform3D::translation
529 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
531 const components::Translation3D& translation, const Rotation3D& rotation
532 ) {
533 return Transform3D(translation, rotation, false);
534 }
535
536 /// From translation & scale only.
537 /// Clears out all other components like `Transform3D::clear_fields`.
538 ///
539 /// \param translation_ \copydoc Transform3D::translation
540 /// \param scale_ Transform3D::scale
541 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
543 const components::Translation3D& translation_, const components::Scale3D& scale_,
544 bool from_parent = false
545 ) {
546 *this = Transform3D().with_translation(translation_).with_scale(scale_);
547 if (from_parent) {
548 *this =
550 }
551 }
552
553 /// From a translation applied after a scale.
554 /// Clears out all other components like `Transform3D::clear_fields`.
555 ///
556 /// \param translation \copydoc Transform3D::translation
557 /// \param scale Transform3D::scale
560 ) {
561 return Transform3D(translation, scale, false);
562 }
563
564 /// From translation & uniform scale only.
565 /// Clears out all other components like `Transform3D::clear_fields`.
566 ///
567 /// \param translation_ \copydoc Transform3D::translation
568 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
569 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
570 ///
571 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
572 /// bool, leading to a call to the wrong overload.
574 const components::Translation3D& translation_, float uniform_scale,
575 bool from_parent = false
576 )
577 : Transform3D(translation_, components::Scale3D(uniform_scale), from_parent) {}
578
579 /// From rotation & scale.
580 /// Clears out all other components like `Transform3D::clear_fields`.
581 ///
582 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
583 /// \param scale_ Transform3D::scale
584 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
586 const Rotation3D& rotation, const components::Scale3D& scale_, bool from_parent = false
587 ) {
588 *this = Transform3D().with_scale(scale_).with_rotation(rotation);
589 if (from_parent) {
590 *this =
592 }
593 }
594
595 /// From rotation & uniform scale.
596 /// Clears out all other components like `Transform3D::clear_fields`.
597 ///
598 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
599 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
600 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
601 ///
602 /// _Implementation note:_ This explicit overload prevents interpretation of the float as
603 /// bool, leading to a call to the wrong overload.
604 Transform3D(const Rotation3D& rotation, float uniform_scale, bool from_parent = false)
605 : Transform3D(rotation, components::Scale3D(uniform_scale), from_parent) {}
606
607 /// From a rotation & scale.
608 /// Clears out all other components like `Transform3D::clear_fields`.
609 ///
610 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
611 /// \param scale Transform3D::scale
613 const Rotation3D& rotation, const components::Scale3D& scale
614 ) {
615 return Transform3D(rotation, scale, false);
616 }
617
618 /// From a rotation & uniform scale.
619 /// Clears out all other components like `Transform3D::clear_fields`.
620 ///
621 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
622 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
623 static Transform3D from_rotation_scale(const Rotation3D& rotation, float uniform_scale) {
624 return Transform3D(rotation, components::Scale3D(uniform_scale), false);
625 }
626
627 /// From rotation only.
628 /// Clears out all other components like `Transform3D::clear_fields`.
629 ///
630 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
631 /// \param from_parent If true, the transform relation to `TransformRelation::ChildFromParent`.
632 Transform3D(const Rotation3D& rotation, bool from_parent = false) {
633 *this = Transform3D().with_rotation(rotation);
634 if (from_parent) {
635 *this =
637 }
638 }
639
640 /// From rotation only.
641 /// Clears out all other components like `Transform3D::clear_fields`.
642 ///
643 /// \param rotation Rotation represented either as a quaternion or axis + angle rotation.
644 static Transform3D from_rotation(const Rotation3D& rotation) {
645 return Transform3D(rotation, false);
646 }
647
648 /// From scale only.
649 /// Clears out all other components like `Transform3D::clear_fields`.
650 ///
651 /// \param scale_ If true, the transform relation to `TransformRelation::ChildFromParent`.
652 /// \param from_parent \copydoc Transform3D::scale
653 Transform3D(const components::Scale3D& scale_, bool from_parent = false) {
654 *this = Transform3D().with_scale(scale_);
655 if (from_parent) {
656 *this =
658 }
659 }
660
661 /// From scale only.
662 /// Clears out all other components like `Transform3D::clear_fields`.
663 ///
664 /// \param scale Transform3D::scale
666 return Transform3D(scale, false);
667 }
668
669 /// From scale only.
670 /// Clears out all other components like `Transform3D::clear_fields`.
671 ///
672 /// \param uniform_scale Uniform scale factor that is applied to all axis equally.
673 static Transform3D from_scale(float uniform_scale) {
674 return Transform3D(components::Scale3D(uniform_scale), false);
675 }
676
677 /// Set the rotation component of the transform using the `rerun::Rotation3D` utility.
679 if (rotation.axis_angle.has_value()) {
680 *this = std::move(*this).with_rotation_axis_angle(rotation.axis_angle.value());
681 }
682 if (rotation.quaternion.has_value()) {
683 *this = std::move(*this).with_quaternion(rotation.quaternion.value());
684 }
685 return std::move(*this);
686 }
687
688 // END of extensions from transform3d_ext.cpp, start of generated code:
689
690 public:
691 Transform3D() = default;
692 Transform3D(Transform3D&& other) = default;
693 Transform3D(const Transform3D& other) = default;
694 Transform3D& operator=(const Transform3D& other) = default;
695 Transform3D& operator=(Transform3D&& other) = default;
696
697 /// Update only some specific fields of a `Transform3D`.
699 return Transform3D();
700 }
701
702 /// Clear all the fields of a `Transform3D`.
704
705 /// Translation vector.
706 ///
707 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
710 .value_or_throw();
711 return std::move(*this);
712 }
713
714 /// This method makes it possible to pack multiple `translation` in a single component batch.
715 ///
716 /// This only makes sense when used in conjunction with `columns`. `with_translation` should
717 /// be used when logging a single row's worth of data.
720 ) && {
722 .value_or_throw();
723 return std::move(*this);
724 }
725
726 /// Rotation via axis + angle.
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.
730 const rerun::components::RotationAxisAngle& _rotation_axis_angle
731 ) && {
734 .value_or_throw();
735 return std::move(*this);
736 }
737
738 /// This method makes it possible to pack multiple `rotation_axis_angle` in a single component batch.
739 ///
740 /// This only makes sense when used in conjunction with `columns`. `with_rotation_axis_angle` should
741 /// be used when logging a single row's worth of data.
743 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angle
744 ) && {
747 .value_or_throw();
748 return std::move(*this);
749 }
750
751 /// Rotation via quaternion.
752 ///
753 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
755 quaternion =
756 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
757 return std::move(*this);
758 }
759
760 /// This method makes it possible to pack multiple `quaternion` in a single component batch.
761 ///
762 /// This only makes sense when used in conjunction with `columns`. `with_quaternion` should
763 /// be used when logging a single row's worth of data.
766 ) && {
767 quaternion =
768 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
769 return std::move(*this);
770 }
771
772 /// Scaling factor.
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 scale = ComponentBatch::from_loggable(_scale, Descriptor_scale).value_or_throw();
777 return std::move(*this);
778 }
779
780 /// This method makes it possible to pack multiple `scale` in a single component batch.
781 ///
782 /// This only makes sense when used in conjunction with `columns`. `with_scale` should
783 /// be used when logging a single row's worth of data.
785 scale = ComponentBatch::from_loggable(_scale, Descriptor_scale).value_or_throw();
786 return std::move(*this);
787 }
788
789 /// 3x3 transformation matrix.
790 ///
791 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
793 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
794 return std::move(*this);
795 }
796
797 /// This method makes it possible to pack multiple `mat3x3` in a single component batch.
798 ///
799 /// This only makes sense when used in conjunction with `columns`. `with_mat3x3` should
800 /// be used when logging a single row's worth of data.
802 ) && {
803 mat3x3 = ComponentBatch::from_loggable(_mat3x3, Descriptor_mat3x3).value_or_throw();
804 return std::move(*this);
805 }
806
807 /// Specifies the relation this transform establishes between this entity and its parent.
808 ///
809 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
811 relation =
812 ComponentBatch::from_loggable(_relation, Descriptor_relation).value_or_throw();
813 return std::move(*this);
814 }
815
816 /// This method makes it possible to pack multiple `relation` in a single component batch.
817 ///
818 /// This only makes sense when used in conjunction with `columns`. `with_relation` should
819 /// be used when logging a single row's worth of data.
822 ) && {
823 relation =
824 ComponentBatch::from_loggable(_relation, Descriptor_relation).value_or_throw();
825 return std::move(*this);
826 }
827
828 /// The child frame this transform transforms from.
829 ///
830 /// 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.
831 /// E.g. if you specified the child frame `"robot_arm"` on an entity named `"my_transforms"`, you may not log transforms
832 /// with the child frame `"robot_arm"` on any other entity than `"my_transforms"` unless one of them was logged with static time.
833 ///
834 /// If not specified, this is set to the implicit transform frame of the current entity path.
835 /// 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`.
836 ///
837 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
838 ///
839 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
842 .value_or_throw();
843 return std::move(*this);
844 }
845
846 /// This method makes it possible to pack multiple `child_frame` in a single component batch.
847 ///
848 /// This only makes sense when used in conjunction with `columns`. `with_child_frame` should
849 /// be used when logging a single row's worth of data.
852 ) && {
854 .value_or_throw();
855 return std::move(*this);
856 }
857
858 /// The parent frame this transform transforms into.
859 ///
860 /// If not specified, this is set to the implicit transform frame of the current entity path's parent.
861 /// This means that if a `archetypes::Transform3D` is set on an entity called `/my/entity/path` then this will default to `tf#/my/entity`.
862 ///
863 /// To set the frame an entity is part of see `archetypes::CoordinateFrame`.
864 ///
865 /// Any update to this field will reset all other transform properties that aren't changed in the same log call or `send_columns` row.
868 .value_or_throw();
869 return std::move(*this);
870 }
871
872 /// This method makes it possible to pack multiple `parent_frame` in a single component batch.
873 ///
874 /// This only makes sense when used in conjunction with `columns`. `with_parent_frame` should
875 /// be used when logging a single row's worth of data.
878 ) && {
880 .value_or_throw();
881 return std::move(*this);
882 }
883
884 /// Partitions the component data into multiple sub-batches.
885 ///
886 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
887 /// instead, via `ComponentBatch::partitioned`.
888 ///
889 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
890 ///
891 /// The specified `lengths` must sum to the total length of the component batch.
893
894 /// Partitions the component data into unit-length sub-batches.
895 ///
896 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
897 /// where `n` is automatically guessed.
899 };
900
901} // namespace rerun::archetypes
902
903namespace rerun {
904 /// \private
905 template <typename T>
906 struct AsComponents;
907
908 /// \private
909 template <>
910 struct AsComponents<archetypes::Transform3D> {
911 /// Serialize all set component batches.
912 static Result<Collection<ComponentBatch>> as_batches(
913 const archetypes::Transform3D& archetype
914 );
915 };
916} // 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:76
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:23
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:219
static constexpr auto Descriptor_rotation_axis_angle
ComponentDescriptor for the rotation_axis_angle field.
Definition transform3d.hpp:284
static RERUN_SDK_EXPORT const Transform3D IDENTITY
Identity transformation.
Definition transform3d.hpp:322
std::optional< ComponentBatch > parent_frame
The parent frame this transform transforms into.
Definition transform3d.hpp:272
std::optional< ComponentBatch > mat3x3
3x3 transformation matrix.
Definition transform3d.hpp:243
Transform3D(const datatypes::Vec3D(&columns)[3], bool from_parent=false)
From 3x3 matrix provided as 3 columns only.
Definition transform3d.hpp:433
Transform3D(const components::Translation3D &translation_, const components::TransformMat3x3 &mat3x3_, bool from_parent=false)
Creates a new 3D transform from translation/matrix.
Definition transform3d.hpp:350
std::optional< ComponentBatch > child_frame
The child frame this transform transforms from.
Definition transform3d.hpp:262
static Transform3D from_translation_scale(const components::Translation3D &translation, const components::Scale3D &scale)
From a translation applied after a scale.
Definition transform3d.hpp:558
Transform3D with_relation(const rerun::components::TransformRelation &_relation) &&
Specifies the relation this transform establishes between this entity and its parent.
Definition transform3d.hpp:810
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:475
static Transform3D from_mat3x3(const components::TransformMat3x3 &mat3x3)
From 3x3 matrix only.
Definition transform3d.hpp:424
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:451
Transform3D(const Rotation3D &rotation, float uniform_scale, bool from_parent=false)
From rotation & uniform scale.
Definition transform3d.hpp:604
Transform3D(const components::Translation3D &translation_, float uniform_scale, bool from_parent=false)
From translation & uniform scale only.
Definition transform3d.hpp:573
Transform3D with_scale(const rerun::components::Scale3D &_scale) &&
Scaling factor.
Definition transform3d.hpp:775
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:308
static RERUN_SDK_EXPORT const Transform3D INVALID
Invalid transformation.
Definition transform3d.hpp:327
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:850
Transform3D with_quaternion(const rerun::components::RotationQuat &_quaternion) &&
Rotation via quaternion.
Definition transform3d.hpp:754
std::optional< ComponentBatch > translation
Translation vector.
Definition transform3d.hpp:223
Transform3D(const components::Translation3D &translation_, const Rotation3D &rotation, bool from_parent=false)
Creates a new rigid transform (translation & rotation only).
Definition transform3d.hpp:514
Transform3D(const components::Translation3D &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:338
Transform3D with_translation(const rerun::components::Translation3D &_translation) &&
Translation vector.
Definition transform3d.hpp:708
Transform3D(const Rotation3D &rotation, bool from_parent=false)
From rotation only.
Definition transform3d.hpp:632
Transform3D(const components::TransformMat3x3 &mat3x3_, bool from_parent=false)
From 3x3 matrix only.
Definition transform3d.hpp:412
static Transform3D update_fields()
Update only some specific fields of a Transform3D.
Definition transform3d.hpp:698
static Transform3D from_rotation_scale(const Rotation3D &rotation, float uniform_scale)
From a rotation & uniform scale.
Definition transform3d.hpp:623
static Transform3D from_translation_mat3x3(const components::Translation3D &translation, const components::TransformMat3x3 &mat3x3)
From a translation applied after a 3x3 matrix.
Definition transform3d.hpp:366
static Transform3D from_rotation_scale(const Rotation3D &rotation, const components::Scale3D &scale)
From a rotation & scale.
Definition transform3d.hpp:612
static Transform3D from_translation(const components::Translation3D &translation)
From a translation.
Definition transform3d.hpp:403
Transform3D with_rotation(const Rotation3D &rotation) &&
Set the rotation component of the transform using the rerun::Rotation3D utility.
Definition transform3d.hpp:678
static Transform3D from_scale(float uniform_scale)
From scale only.
Definition transform3d.hpp:673
std::optional< ComponentBatch > rotation_axis_angle
Rotation via axis + angle.
Definition transform3d.hpp:228
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:801
static constexpr auto Descriptor_translation
ComponentDescriptor for the translation field.
Definition transform3d.hpp:279
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:742
static constexpr auto Descriptor_quaternion
ComponentDescriptor for the quaternion field.
Definition transform3d.hpp:289
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:488
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition transform3d.hpp:276
static constexpr auto Descriptor_parent_frame
ComponentDescriptor for the parent_frame field.
Definition transform3d.hpp:313
static constexpr auto Descriptor_scale
ComponentDescriptor for the scale field.
Definition transform3d.hpp:294
Transform3D(const components::Scale3D &scale_, bool from_parent=false)
From scale only.
Definition transform3d.hpp:653
static constexpr auto Descriptor_mat3x3
ComponentDescriptor for the mat3x3 field.
Definition transform3d.hpp:298
static Transform3D from_translation_mat3x3(const components::Translation3D &translation, const datatypes::Vec3D(&columns)[3])
From a translation applied after a 3x3 matrix provided as 3 columns.
Definition transform3d.hpp:377
static Transform3D from_translation_rotation(const components::Translation3D &translation, const Rotation3D &rotation)
From a rotation & scale.
Definition transform3d.hpp:530
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > quaternion
Rotation via quaternion.
Definition transform3d.hpp:233
Transform3D with_child_frame(const rerun::components::TransformFrameId &_child_frame) &&
The child frame this transform transforms from.
Definition transform3d.hpp:840
Transform3D(const Rotation3D &rotation, const components::Scale3D &scale_, bool from_parent=false)
From rotation & scale.
Definition transform3d.hpp:585
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:820
Transform3D(const components::Translation3D &translation_, bool from_parent=false)
From translation only.
Definition transform3d.hpp:391
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:764
Transform3D with_rotation_axis_angle(const rerun::components::RotationAxisAngle &_rotation_axis_angle) &&
Rotation via axis + angle.
Definition transform3d.hpp:729
Transform3D with_parent_frame(const rerun::components::TransformFrameId &_parent_frame) &&
The parent frame this transform transforms into.
Definition transform3d.hpp:866
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:718
Transform3D(const components::Translation3D &translation_, const components::Scale3D &scale_, bool from_parent=false)
From translation & scale only.
Definition transform3d.hpp:542
std::optional< ComponentBatch > relation
Specifies the relation this transform establishes between this entity and its parent.
Definition transform3d.hpp:248
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:784
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:501
Transform3D with_mat3x3(const rerun::components::TransformMat3x3 &_mat3x3) &&
3x3 transformation matrix.
Definition transform3d.hpp:792
static constexpr auto Descriptor_relation
ComponentDescriptor for the relation field.
Definition transform3d.hpp:303
static Transform3D from_scale(const components::Scale3D &scale)
From scale only.
Definition transform3d.hpp:665
static Transform3D from_mat3x3(const datatypes::Vec3D(&columns)[3])
From 3x3 matrix provided as 3 columns only.
Definition transform3d.hpp:440
std::optional< ComponentBatch > scale
Scaling factor.
Definition transform3d.hpp:238
static Transform3D from_rotation(const Rotation3D &rotation)
From rotation only.
Definition transform3d.hpp:644
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:876
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
Datatype: A vector in 3D space.
Definition vec3d.hpp:20