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 1.7KB

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