From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- graphics/sketch/geomio.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 graphics/sketch/geomio.c (limited to 'graphics/sketch/geomio.c') diff --git a/graphics/sketch/geomio.c b/graphics/sketch/geomio.c new file mode 100644 index 0000000000..57f57dd779 --- /dev/null +++ b/graphics/sketch/geomio.c @@ -0,0 +1,74 @@ +/* geomio.c + Copyright (C) 2005,2006,2007 Eugene K. Ressler, Jr. + +This file is part of Sketch, a small, simple system for making +3d drawings with LaTeX and the PSTricks or TikZ package. + +Sketch is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +Sketch is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Sketch; see the file COPYING.txt. If not, see +http://www.gnu.org/copyleft */ + +#include "geomio.h" + +void +print_pt_2d (FILE * f, POINT_2D pt) +{ + fprintf (f, "(%.3f,%.3f)", pt[X], pt[Y]); +} + +void +print_pt_3d (FILE * f, POINT_3D pt) +{ + fprintf (f, "(%.3f,%.3f,%.3f)", pt[X], pt[Y], pt[Z]); +} + +void +print_polyline_3d (FILE * f, POLYLINE_3D * polyline) +{ + int i; + + fprintf (f, "\\line"); + for (i = 0; i < polyline->n_vertices; i++) + print_pt_3d (f, polyline->v[i]); + fprintf (f, "\n"); +} + +void +print_polygon_2d (FILE * f, POLYGON_2D * polygon) +{ + int i; + + fprintf (f, "\\polygon"); + for (i = 0; i < polygon->n_sides; i++) + print_pt_2d (f, polygon->v[i]); + fprintf (f, "\n"); +} + +void +print_polygon_3d (FILE * f, POLYGON_3D * polygon) +{ + int i; + + fprintf (f, "\\polygon"); + for (i = 0; i < polygon->n_sides; i++) + print_pt_3d (f, polygon->v[i]); + fprintf (f, "\n"); +} + +void +print_plane (FILE * f, PLANE * plane) +{ + fprintf (f, "\\plane[n=%.3f %.3f %.3f,p=%.3f %.3f %.3f,c=%.3f]\n", + plane->n[X], plane->n[Y], plane->n[Z], + plane->p[X], plane->p[Y], plane->p[Z], plane->c); +} -- cgit v1.2.3