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