Geometry.pm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #/|/ Copyright (c) Prusa Research 2017 - 2022 Vojtěch Bubník @bubnikv
  2. #/|/ Copyright (c) Slic3r 2011 - 2015 Alessandro Ranellucci @alranel
  3. #/|/ Copyright (c) 2013 Jose Luis Perez Diez
  4. #/|/ Copyright (c) 2013 Anders Sundman
  5. #/|/ Copyright (c) 2013 Jesse Vincent
  6. #/|/ Copyright (c) 2012 Mike Sheldrake @mesheldrake
  7. #/|/ Copyright (c) 2012 Mark Hindess
  8. #/|/
  9. #/|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
  10. #/|/
  11. package Slic3r::Geometry;
  12. use strict;
  13. use warnings;
  14. require Exporter;
  15. our @ISA = qw(Exporter);
  16. # Exported by this module. The last section starting with convex_hull is exported by Geometry.xsp
  17. our @EXPORT_OK = qw(
  18. PI epsilon
  19. scale
  20. unscale
  21. scaled_epsilon
  22. X Y Z
  23. convex_hull
  24. deg2rad
  25. rad2deg
  26. );
  27. use constant PI => 4 * atan2(1, 1);
  28. use constant A => 0;
  29. use constant B => 1;
  30. use constant X1 => 0;
  31. use constant Y1 => 1;
  32. use constant X2 => 2;
  33. use constant Y2 => 3;
  34. sub epsilon () { 1E-4 }
  35. sub scaled_epsilon () { epsilon / &Slic3r::SCALING_FACTOR }
  36. sub scale ($) { $_[0] / &Slic3r::SCALING_FACTOR }
  37. sub unscale ($) { $_[0] * &Slic3r::SCALING_FACTOR }
  38. 1;