Rerun C++ SDK
Loading...
Searching...
No Matches
mat4x4.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/mat4x4.fbs".
3
4#pragma once
5
6#include "../rerun_sdk_export.hpp"
7#include "../result.hpp"
8#include "vec4d.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 4x4 Matrix.
22 ///
23 /// Matrices in Rerun are stored as flat list of coefficients in column-major order:
24 /// ```text
25 /// column 0 column 1 column 2 column 3
26 /// --------------------------------------------------------------------
27 /// row 0 | flat_columns[0] flat_columns[4] flat_columns[8] flat_columns[12]
28 /// row 1 | flat_columns[1] flat_columns[5] flat_columns[9] flat_columns[13]
29 /// row 2 | flat_columns[2] flat_columns[6] flat_columns[10] flat_columns[14]
30 /// row 3 | flat_columns[3] flat_columns[7] flat_columns[11] flat_columns[15]
31 /// ```
32 struct Mat4x4 {
33 /// Flat list of matrix coefficients in column-major order.
34 std::array<float, 16> flat_columns;
35
36 public: // START of extensions from mat4x4_ext.cpp:
37 RERUN_SDK_EXPORT static const Mat4x4 IDENTITY;
38
39 /// Creates a new 4x4 matrix from 3 *columns* of 4 elements each.
40 Mat4x4(const Vec4D (&columns)[4])
42 columns[0].x(),
43 columns[0].y(),
44 columns[0].z(),
45 columns[0].w(),
46 columns[1].x(),
47 columns[1].y(),
48 columns[1].z(),
49 columns[1].w(),
50 columns[2].x(),
51 columns[2].y(),
52 columns[2].z(),
53 columns[2].w(),
54 columns[3].x(),
55 columns[3].y(),
56 columns[3].z(),
57 columns[3].w(),
58 } {}
59
60 /// Construct a new 4x4 matrix from a pointer to 16 floats (in column major order).
61 explicit Mat4x4(const float* elements)
63 elements[0],
64 elements[1],
65 elements[2],
66 elements[3],
67 elements[4],
68 elements[5],
69 elements[6],
70 elements[7],
71 elements[8],
72 elements[9],
73 elements[10],
74 elements[11],
75 elements[12],
76 elements[13],
77 elements[14],
78 elements[15],
79 } {}
80
81 // END of extensions from mat4x4_ext.cpp, start of generated code:
82
83 public:
84 Mat4x4() = default;
85
86 Mat4x4(std::array<float, 16> flat_columns_) : flat_columns(flat_columns_) {}
87
88 Mat4x4& operator=(std::array<float, 16> flat_columns_) {
89 flat_columns = flat_columns_;
90 return *this;
91 }
92 };
93} // namespace rerun::datatypes
94
95namespace rerun {
96 template <typename T>
97 struct Loggable;
98
99 /// \private
100 template <>
101 struct Loggable<datatypes::Mat4x4> {
102 static constexpr const char Name[] = "rerun.datatypes.Mat4x4";
103
104 /// Returns the arrow data type this type corresponds to.
105 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
106
107 /// Serializes an array of `rerun::datatypes::Mat4x4` into an arrow array.
108 static Result<std::shared_ptr<arrow::Array>> to_arrow(
109 const datatypes::Mat4x4* instances, size_t num_instances
110 );
111
112 /// Fills an arrow array builder with an array of this type.
113 static rerun::Error fill_arrow_array_builder(
114 arrow::FixedSizeListBuilder* builder, const datatypes::Mat4x4* elements,
115 size_t num_elements
116 );
117 };
118} // 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 4x4 Matrix.
Definition mat4x4.hpp:32
std::array< float, 16 > flat_columns
Flat list of matrix coefficients in column-major order.
Definition mat4x4.hpp:34
Mat4x4(const Vec4D(&columns)[4])
Creates a new 4x4 matrix from 3 columns of 4 elements each.
Definition mat4x4.hpp:40
Mat4x4(const float *elements)
Construct a new 4x4 matrix from a pointer to 16 floats (in column major order).
Definition mat4x4.hpp:61
Datatype: A vector in 4D space.
Definition vec4d.hpp:20