Prusa MINI Firmware overview
matrix_3x3 Struct Reference

#include <vector_3.h>

Collaboration diagram for matrix_3x3:

Public Member Functions

void set_to_identity ()
 
void debug (PGM_P const title)
 

Static Public Member Functions

static matrix_3x3 create_from_rows (const vector_3 &row_0, const vector_3 &row_1, const vector_3 &row_2)
 
static matrix_3x3 create_look_at (const vector_3 &target)
 
static matrix_3x3 transpose (const matrix_3x3 &original)
 

Public Attributes

abc_float_t vectors [3]
 

Member Function Documentation

◆ create_from_rows()

matrix_3x3 matrix_3x3::create_from_rows ( const vector_3 row_0,
const vector_3 row_1,
const vector_3 row_2 
)
static
101  {
102  //row_0.debug(PSTR("row_0"));
103  //row_1.debug(PSTR("row_1"));
104  //row_2.debug(PSTR("row_2"));
105  matrix_3x3 new_matrix;
106  new_matrix.vectors[0] = row_0;
107  new_matrix.vectors[1] = row_1;
108  new_matrix.vectors[2] = row_2;
109  //new_matrix.debug(PSTR("new_matrix"));
110  return new_matrix;
111 }
Here is the caller graph for this function:

◆ create_look_at()

matrix_3x3 matrix_3x3::create_look_at ( const vector_3 target)
static
114  {
115  const vector_3 z_row = target.get_normal(),
116  x_row = vector_3(1, 0, -target.x / target.z).get_normal(),
117  y_row = vector_3::cross(z_row, x_row).get_normal();
118 
119  // x_row.debug(PSTR("x_row"));
120  // y_row.debug(PSTR("y_row"));
121  // z_row.debug(PSTR("z_row"));
122 
123  // create the matrix already correctly transposed
124  matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);
125 
126  // rot.debug(PSTR("rot"));
127  return rot;
128 }
Here is the call graph for this function:

◆ transpose()

matrix_3x3 matrix_3x3::transpose ( const matrix_3x3 original)
static
131  {
132  matrix_3x3 new_matrix;
133  for (uint8_t i = 0; i < 3; i++)
134  for (uint8_t j = 0; j < 3; j++)
135  new_matrix.vectors[i][j] = original.vectors[j][i];
136  return new_matrix;
137 }
Here is the caller graph for this function:

◆ set_to_identity()

void matrix_3x3::set_to_identity ( )
94  {
95  for (uint8_t i = 0; i < 3; i++)
96  for (uint8_t j = 0; j < 3; j++)
97  vectors[i][j] = float(i == j);
98 }
Here is the caller graph for this function:

◆ debug()

void matrix_3x3::debug ( PGM_P const  title)
139  {
140  if (title != nullptr) {
141  serialprintPGM(title);
142  SERIAL_EOL();
143  }
144  for (uint8_t i = 0; i < 3; i++) {
145  for (uint8_t j = 0; j < 3; j++) {
146  if (vectors[i][j] >= 0.0) SERIAL_CHAR('+');
147  SERIAL_ECHO_F(vectors[i][j], 6);
148  SERIAL_CHAR(' ');
149  }
150  SERIAL_EOL();
151  }
152 }
Here is the call graph for this function:

Member Data Documentation

◆ vectors

abc_float_t matrix_3x3::vectors[3]
XYZval::z
T z
Definition: types.h:286
SERIAL_CHAR
#define SERIAL_CHAR(x)
Definition: serial.h:69
XYZval::x
T x
Definition: types.h:286
vector_3::get_normal
vector_3 get_normal() const
Definition: vector_3.cpp:61
i
uint8_t i
Definition: screen_test_graph.c:72
matrix_3x3
Definition: vector_3.h:73
vector_3::cross
static vector_3 cross(const vector_3 &a, const vector_3 &b)
Definition: vector_3.cpp:54
SERIAL_ECHO_F
#define SERIAL_ECHO_F(V...)
Definition: serial.h:71
matrix_3x3::vectors
abc_float_t vectors[3]
Definition: vector_3.h:74
uint8_t
const uint8_t[]
Definition: 404_html.c:3
SERIAL_EOL
#define SERIAL_EOL()
Definition: serial.h:181
vector_3
Definition: vector_3.h:47
matrix_3x3::create_from_rows
static matrix_3x3 create_from_rows(const vector_3 &row_0, const vector_3 &row_1, const vector_3 &row_2)
Definition: vector_3.cpp:101
serialprintPGM
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35