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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. #pragma once
  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. #include "../core/types.h"
  42. class matrix_3x3;
  43. struct vector_3 : xyz_float_t {
  44. vector_3(const float &_x, const float &_y, const float &_z) { set(_x, _y, _z); }
  45. vector_3(const xy_float_t &in) { set(in.x, in.y); }
  46. vector_3(const xyz_float_t &in) { set(in.x, in.y, in.z); }
  47. vector_3(const xyze_float_t &in) { set(in.x, in.y, in.z); }
  48. vector_3() { reset(); }
  49. // Factory method
  50. static vector_3 cross(const vector_3 &a, const vector_3 &b);
  51. // Modifiers
  52. void normalize();
  53. void apply_rotation(const matrix_3x3 &matrix);
  54. // Accessors
  55. float get_length() const;
  56. vector_3 get_normal() const;
  57. // Operators
  58. FORCE_INLINE vector_3 operator+(const vector_3 &v) const { vector_3 o = *this; o += v; return o; }
  59. FORCE_INLINE vector_3 operator-(const vector_3 &v) const { vector_3 o = *this; o -= v; return o; }
  60. FORCE_INLINE vector_3 operator*(const float &v) const { vector_3 o = *this; o *= v; return o; }
  61. void debug(PGM_P const title);
  62. };
  63. struct matrix_3x3 {
  64. abc_float_t vectors[3];
  65. // Factory methods
  66. static matrix_3x3 create_from_rows(const vector_3 &row_0, const vector_3 &row_1, const vector_3 &row_2);
  67. static matrix_3x3 create_look_at(const vector_3 &target);
  68. static matrix_3x3 transpose(const matrix_3x3 &original);
  69. void set_to_identity();
  70. void debug(PGM_P const title);
  71. };
  72. void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, float &x, float &y, float &z);
  73. FORCE_INLINE void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, xyz_pos_t &pos) {
  74. apply_rotation_xyz(rotationMatrix, pos.x, pos.y, pos.z);
  75. }