Subversion Repositories MK-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
/**
2
 * Marlin 3D Printer Firmware
3
 * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
 *
5
 * Based on Sprinter and grbl.
6
 * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
 
23
/**
24
  vector_3.cpp - Vector library for bed leveling
25
  Copyright (c) 2012 Lars Brubaker.  All right reserved.
26
 
27
  This library is free software; you can redistribute it and/or
28
  modify it under the terms of the GNU Lesser General Public
29
  License as published by the Free Software Foundation; either
30
  version 2.1 of the License, or (at your option) any later version.
31
 
32
  This library is distributed in the hope that it will be useful,
33
  but WITHOUT ANY WARRANTY; without even the implied warranty of
34
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35
  Lesser General Public License for more details.
36
 
37
  You should have received a copy of the GNU Lesser General Public
38
  License along with this library; if not, write to the Free Software
39
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
40
*/
41
#ifndef VECTOR_3_H
42
#define VECTOR_3_H
43
 
44
class matrix_3x3;
45
 
46
struct vector_3 {
47
  float x, y, z;
48
 
49
  vector_3();
50
  vector_3(float x, float y, float z);
51
 
52
  static vector_3 cross(vector_3 a, vector_3 b);
53
 
54
  vector_3 operator+(vector_3 v);
55
  vector_3 operator-(vector_3 v);
56
  void normalize();
57
  float get_length();
58
  vector_3 get_normal();
59
 
60
  void debug(const char * const title);
61
 
62
  void apply_rotation(matrix_3x3 matrix);
63
};
64
 
65
struct matrix_3x3 {
66
  float matrix[9];
67
 
68
  static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2);
69
  static matrix_3x3 create_look_at(vector_3 target);
70
  static matrix_3x3 transpose(matrix_3x3 original);
71
 
72
  void set_to_identity();
73
 
74
  void debug(const char * const title);
75
};
76
 
77
 
78
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float &y, float &z);
79
 
80
#endif // VECTOR_3_H