Prusa3d Marlin fork
vector_3.h
1 /*
2  vector_3.cpp - Vector library for bed leveling
3  Copyright (c) 2012 Lars Brubaker. All right reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #ifndef VECTOR_3_H
20 #define VECTOR_3_H
21 
22 #ifdef ENABLE_AUTO_BED_LEVELING
23 class matrix_3x3;
24 
25 struct vector_3
26 {
27  float x, y, z;
28 
29  vector_3();
30  vector_3(float x, float y, float z);
31 
32  static vector_3 cross(vector_3 a, vector_3 b);
33 
34  vector_3 operator+(vector_3 v);
35  vector_3 operator-(vector_3 v);
36  void normalize();
37  float get_length();
38  vector_3 get_normal();
39 
40  void debug(char* title);
41 
42  void apply_rotation(matrix_3x3 matrix);
43 };
44 
45 struct matrix_3x3
46 {
47  float matrix[9];
48 
49  static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2);
50  static matrix_3x3 create_look_at(vector_3 target);
51  static matrix_3x3 transpose(matrix_3x3 original);
52 
53  void set_to_identity();
54 
55  void debug(char* title);
56 };
57 
58 
59 void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float& y, float& z);
60 #endif // ENABLE_AUTO_BED_LEVELING
61 
62 #endif // VECTOR_3_H
Definition: vector_3.h:46
Definition: vector_3.h:26