C   6

geomio.c

Guest on 20th July 2021 03:10:02 PM

  1. /* geomio.c
  2.    Copyright (C)  Eugene K. Ressler, Jr.
  3.  
  4. This file is part of Sketch, a small, simple system for making
  5. 3d drawings with LaTeX and the PSTricks or TikZ package.
  6.  
  7. Sketch 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 3, or (at your option)
  10. any later version.
  11.  
  12. Sketch is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Sketch; see the file COPYING.txt.  If not, see
  19. http://www.gnu.org/copyleft */
  20.  
  21. #include "geomio.h"
  22.  
  23. void
  24. print_pt_2d (FILE * f, POINT_2D pt)
  25. {
  26.   fprintf (f, "(%.3f,%.3f)", pt[X], pt[Y]);
  27. }
  28.  
  29. void
  30. print_pt_3d (FILE * f, POINT_3D pt)
  31. {
  32.   fprintf (f, "(%.3f,%.3f,%.3f)", pt[X], pt[Y], pt[Z]);
  33. }
  34.  
  35. void
  36. print_polyline_3d (FILE * f, POLYLINE_3D * polyline)
  37. {
  38.   int i;
  39.  
  40.   fprintf (f, "\\line");
  41.   for (i = 0; i < polyline->n_vertices; i++)
  42.     print_pt_3d (f, polyline->v[i]);
  43.   fprintf (f, "\n");
  44. }
  45.  
  46. void
  47. print_polygon_2d (FILE * f, POLYGON_2D * polygon)
  48. {
  49.   int i;
  50.  
  51.   fprintf (f, "\\polygon");
  52.   for (i = 0; i < polygon->n_sides; i++)
  53.     print_pt_2d (f, polygon->v[i]);
  54.   fprintf (f, "\n");
  55. }
  56.  
  57. void
  58. print_polygon_3d (FILE * f, POLYGON_3D * polygon)
  59. {
  60.   int i;
  61.  
  62.   fprintf (f, "\\polygon");
  63.   for (i = 0; i < polygon->n_sides; i++)
  64.     print_pt_3d (f, polygon->v[i]);
  65.   fprintf (f, "\n");
  66. }
  67.  
  68. void
  69. print_plane (FILE * f, PLANE * plane)
  70. {
  71.   fprintf (f, "\\plane[n=%.3f %.3f %.3f,p=%.3f %.3f %.3f,c=%.3f]\n",
  72.            plane->n[X], plane->n[Y], plane->n[Z],
  73.            plane->p[X], plane->p[Y], plane->p[Z], plane->c);
  74. }

Raw Paste


Login or Register to edit or fork this paste. It's free.