Rerun C++ SDK
Loading...
Searching...
No Matches
quaternion.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_types/definitions/rerun/datatypes/quaternion.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../rerun_sdk_export.hpp"
8#include "../result.hpp"
9
10#include <array>
11#include <cstdint>
12#include <memory>
13
14namespace arrow {
15 class Array;
16 class DataType;
17 class FixedSizeListBuilder;
18} // namespace arrow
19
20namespace rerun::datatypes {
21 /// **Datatype**: A Quaternion represented by 4 real numbers.
22 ///
23 /// Note: although the x,y,z,w components of the quaternion will be passed through to the
24 /// datastore as provided, when used in the Viewer Quaternions will always be normalized.
25 struct Quaternion {
26 std::array<float, 4> xyzw;
27
28 public: // START of extensions from quaternion_ext.cpp:
29 RERUN_SDK_EXPORT static const Quaternion IDENTITY;
30 RERUN_SDK_EXPORT static const Quaternion INVALID;
31
32 /// Construct Quaternion from x/y/z/w values.
33 static Quaternion from_xyzw(float x, float y, float z, float w) {
34 return Quaternion::from_xyzw({x, y, z, w});
35 }
36
37 /// Construct Quaternion from w/x/y/z values.
38 static Quaternion from_wxyz(float w, float x, float y, float z) {
39 return Quaternion::from_xyzw(x, y, z, w);
40 }
41
42 /// Construct Quaternion from x/y/z/w array.
43 static Quaternion from_xyzw(std::array<float, 4> xyzw_) {
44 Quaternion q;
45 q.xyzw = xyzw_;
46 return q;
47 }
48
49 /// Construct Quaternion from w/x/y/z array.
50 static Quaternion from_wxyz(std::array<float, 4> wxyz_) {
51 return Quaternion::from_xyzw(wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]);
52 }
53
54 /// Construct Quaternion from x/y/z/w float pointer.
55 static Quaternion from_xyzw(const float* xyzw_) {
56 return Quaternion::from_xyzw(xyzw_[0], xyzw_[1], xyzw_[2], xyzw_[3]);
57 }
58
59 /// Construct Quaternion from w/x/y/z float pointer.
60 static Quaternion from_wxyz(const float* wxyz_) {
61 return Quaternion::from_xyzw(wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]);
62 }
63
64 float x() const {
65 return xyzw[0];
66 }
67
68 float y() const {
69 return xyzw[1];
70 }
71
72 float z() const {
73 return xyzw[2];
74 }
75
76 float w() const {
77 return xyzw[3];
78 }
79
80 // END of extensions from quaternion_ext.cpp, start of generated code:
81
82 public:
83 Quaternion() = default;
84 };
85} // namespace rerun::datatypes
86
87namespace rerun {
88 template <typename T>
89 struct Loggable;
90
91 /// \private
92 template <>
93 struct Loggable<datatypes::Quaternion> {
94 static constexpr ComponentDescriptor Descriptor = "rerun.datatypes.Quaternion";
95
96 /// Returns the arrow data type this type corresponds to.
97 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
98
99 /// Serializes an array of `rerun::datatypes::Quaternion` into an arrow array.
100 static Result<std::shared_ptr<arrow::Array>> to_arrow(
101 const datatypes::Quaternion* instances, size_t num_instances
102 );
103
104 /// Fills an arrow array builder with an array of this type.
105 static rerun::Error fill_arrow_array_builder(
106 arrow::FixedSizeListBuilder* builder, const datatypes::Quaternion* elements,
107 size_t num_elements
108 );
109 };
110} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:83
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Datatype: A Quaternion represented by 4 real numbers.
Definition quaternion.hpp:25
static Quaternion from_wxyz(const float *wxyz_)
Construct Quaternion from w/x/y/z float pointer.
Definition quaternion.hpp:60
static Quaternion from_wxyz(std::array< float, 4 > wxyz_)
Construct Quaternion from w/x/y/z array.
Definition quaternion.hpp:50
static Quaternion from_wxyz(float w, float x, float y, float z)
Construct Quaternion from w/x/y/z values.
Definition quaternion.hpp:38
static Quaternion from_xyzw(const float *xyzw_)
Construct Quaternion from x/y/z/w float pointer.
Definition quaternion.hpp:55
static Quaternion from_xyzw(float x, float y, float z, float w)
Construct Quaternion from x/y/z/w values.
Definition quaternion.hpp:33
static Quaternion from_xyzw(std::array< float, 4 > xyzw_)
Construct Quaternion from x/y/z/w array.
Definition quaternion.hpp:43