Polygon.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _Polygon_h_
  2. #define _Polygon_h_
  3. /* Polygon.h
  4. *
  5. * Copyright (C) 1992-2011,2015,2017 Paul Boersma
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Data.h"
  21. #include "Graphics.h"
  22. #include "Polygon_def.h"
  23. autoPolygon Polygon_create (integer numberOfPoints);
  24. /*
  25. Function:
  26. create a new instance of Polygon.
  27. Return value:
  28. the newly created object.
  29. Precondition:
  30. numberOfPoints >= 1;
  31. Failure:
  32. Out of memory.
  33. Postconditions:
  34. result -> numberOfPoints == numberOfPoints;
  35. result -> x [1..numberOfPoints] == 0.0;
  36. result -> y [1..numberOfPoints] == 0.0;
  37. */
  38. void Polygon_randomize (Polygon me); /* Randomize the order of the points. */
  39. double Polygon_perimeter (Polygon me); /* Return the length of the closed path through all points. */
  40. void Polygon_salesperson (Polygon me, integer numberOfIterations);
  41. /*
  42. Function:
  43. change the order of the points in such a way that it defines the shortest closed path.
  44. Preconditions:
  45. !! me;
  46. numberOfIterations >= 1;
  47. Postconditions:
  48. my numberOfPoints == my old numberOfPoints;
  49. Polygon_perimeter (me) <= old Polygon_perimeter (me);
  50. */
  51. /*** Drawing routines. ***/
  52. void Polygon_draw (Polygon me, Graphics g, double xmin, double xmax, double ymin, double ymax);
  53. void Polygon_drawClosed (Polygon me, Graphics g, double xmin, double xmax, double ymin, double ymax);
  54. void Polygon_paint (Polygon me, Graphics g, Graphics_Colour colour, double xmin, double xmax, double ymin, double ymax);
  55. void Polygon_drawCircles (Polygon me, Graphics g,
  56. double xmin, double xmax, double ymin, double ymax, double diameter_mm);
  57. void Polygon_paintCircles (Polygon me, Graphics g,
  58. double xmin, double xmax, double ymin, double ymax, double diameter_mm);
  59. void Polygons_drawConnection (Polygon me, Polygon thee, Graphics g,
  60. double xmin, double xmax, double ymin, double ymax, int hasArrow, double relativeLength);
  61. /* End of file Polygon.h */
  62. #endif