Rerun C++ SDK
Loading...
Searching...
No Matches
mat4x4.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/mat4x4.fbs".
3
4#pragma once
5
6#include "../result.hpp"
7#include "vec4d.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 4x4 Matrix.
21 ///
22 /// Matrices in Rerun are stored as flat list of coefficients in column-major order:
23 /// ```text
24 /// column 0 column 1 column 2 column 3
25 /// --------------------------------------------------------------------
26 /// row 0 | flat_columns[0] flat_columns[4] flat_columns[8] flat_columns[12]
27 /// row 1 | flat_columns[1] flat_columns[5] flat_columns[9] flat_columns[13]
28 /// row 2 | flat_columns[2] flat_columns[6] flat_columns[10] flat_columns[14]
29 /// row 3 | flat_columns[3] flat_columns[7] flat_columns[11] flat_columns[15]
30 /// ```
31 struct Mat4x4 {
32 /// Flat list of matrix coefficients in column-major order.
33 std::array<float, 16> flat_columns;
34
35 public:
36 // Extensions to generated type defined in 'mat4x4_ext.cpp'
37
38 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 row 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 public:
83 Mat4x4() = default;
84
85 Mat4x4(std::array<float, 16> flat_columns_) : flat_columns(flat_columns_) {}
86
87 Mat4x4& operator=(std::array<float, 16> flat_columns_) {
88 flat_columns = flat_columns_;
89 return *this;
90 }
91 };
92} // namespace rerun::datatypes
93
94namespace rerun {
95 template <typename T>
96 struct Loggable;
97
98 /// \private
99 template <>
100 struct Loggable<datatypes::Mat4x4> {
101 static constexpr const char Name[] = "rerun.datatypes.Mat4x4";
102
103 /// Returns the arrow data type this type corresponds to.
104 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
105
106 /// Fills an arrow array builder with an array of this type.
107 static rerun::Error fill_arrow_array_builder(
108 arrow::FixedSizeListBuilder* builder, const datatypes::Mat4x4* elements,
109 size_t num_elements
110 );
111
112 /// Serializes an array of `rerun::datatypes::Mat4x4` into an arrow array.
113 static Result<std::shared_ptr<arrow::Array>> to_arrow(
114 const datatypes::Mat4x4* instances, size_t num_instances
115 );
116 };
117} // 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 4x4 Matrix.
Definition mat4x4.hpp:31
std::array< float, 16 > flat_columns
Flat list of matrix coefficients in column-major order.
Definition mat4x4.hpp:33
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 row major order).
Definition mat4x4.hpp:62
Datatype: A vector in 4D space.
Definition vec4d.hpp:20