6#include "../result.hpp"
7#include "quaternion.hpp"
8#include "rotation_axis_angle.hpp"
19 class DenseUnionBuilder;
25 enum class Rotation3DTag : uint8_t {
33 union Rotation3DData {
41 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(Rotation3DData));
46 void swap(Rotation3DData& other)
noexcept {
48 char temp[
sizeof(Rotation3DData)];
49 void* otherbytes =
reinterpret_cast<void*
>(&other);
50 void* thisbytes =
reinterpret_cast<void*
>(
this);
51 std::memcpy(temp, thisbytes,
sizeof(Rotation3DData));
52 std::memcpy(thisbytes, otherbytes,
sizeof(Rotation3DData));
53 std::memcpy(otherbytes, temp,
sizeof(Rotation3DData));
60 Rotation3D() : _tag(detail::Rotation3DTag::None) {}
64 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
65 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
66 std::memcpy(thisbytes, otherbytes,
sizeof(detail::Rotation3DData));
79 Rotation3D& operator=(Rotation3D&& other)
noexcept {
87 static const Rotation3D IDENTITY;
89 void swap(Rotation3D& other)
noexcept {
90 std::swap(this->_tag, other._tag);
91 this->_data.swap(other._data);
107 self._tag = detail::Rotation3DTag::Quaternion;
115 self._tag = detail::Rotation3DTag::AxisAngle;
122 if (_tag == detail::Rotation3DTag::Quaternion) {
123 return &_data.quaternion;
131 if (_tag == detail::Rotation3DTag::AxisAngle) {
132 return &_data.axis_angle;
139 const detail::Rotation3DData& get_union_data()
const {
144 detail::Rotation3DTag get_union_tag()
const {
149 detail::Rotation3DTag _tag;
150 detail::Rotation3DData _data;
155 template <
typename T>
160 struct Loggable<datatypes::Rotation3D> {
161 static constexpr const char Name[] =
"rerun.datatypes.Rotation3D";
164 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
168 arrow::DenseUnionBuilder* builder,
const datatypes::Rotation3D* elements,
173 static Result<std::shared_ptr<arrow::Array>> to_arrow(
174 const datatypes::Rotation3D* instances,
size_t num_instances
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
Datatype: A 3D rotation.
Definition rotation3d.hpp:59
Rotation3D(rerun::datatypes::Quaternion quaternion)
Rotation defined by a quaternion.
Definition rotation3d.hpp:95
static Rotation3D quaternion(rerun::datatypes::Quaternion quaternion)
Rotation defined by a quaternion.
Definition rotation3d.hpp:105
static Rotation3D axis_angle(rerun::datatypes::RotationAxisAngle axis_angle)
Rotation defined with an axis and an angle.
Definition rotation3d.hpp:113
const rerun::datatypes::RotationAxisAngle * get_axis_angle() const
Return a pointer to axis_angle if the union is in that state, otherwise nullptr.
Definition rotation3d.hpp:130
Rotation3D(rerun::datatypes::RotationAxisAngle axis_angle)
Rotation defined with an axis and an angle.
Definition rotation3d.hpp:100
Rotation3D(const Rotation3D &other)
Copy constructor.
Definition rotation3d.hpp:63
const rerun::datatypes::Quaternion * get_quaternion() const
Return a pointer to quaternion if the union is in that state, otherwise nullptr.
Definition rotation3d.hpp:121
Datatype: 3D rotation represented by a rotation around a given axis.
Definition rotation_axis_angle.hpp:21