My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vector_3.h 2.5KB

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