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