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