/****************************************************************************/ /* (C) Copyright 1993 Universidade Estadual de Campinas (UNICAMP) */ /* Campinas, SP, Brazil */ /* */ /* This file can be freely distributed, modified, and used for any */ /* non-commercial purpose, provided that this copyright and authorship */ /* notice be included in any copy or derived version of this file. */ /* */ /* DISCLAIMER: This software is offered ``as is'', without any guarantee */ /* as to fitness for any particular purpose. Neither the copyright */ /* holder nor the authors or their employers can be held responsible for */ /* any damages that may result from its use. */ /****************************************************************************/ /* See fltzeros2.h */ #include "fltzeros2.h" #include #include #include #include #include #include #include /*** PROTOTYPES FOR INTERNAL ROUTINES ***/ void fltzeros2_in_triangle( FILE *psfile, double xa, double ya, Float za, double xb, double yb, Float zb, double xc, double yc, Float zc ); /* Draws intersection of triangle abc with plane z=0. */ /* Includes edges ab and bc but not ac. */ /*** IMPLEMENTATIONS ***/ void fltzeros2_plot( FILE *psfile, Float f (Float x, Float y), Interval xd, Interval yd, int m ) { Interval xv, yv; int xi, yi; Float xm, ym; Float f00, f01, f10, f11, fmm; ROUND_NEAR; ps_begin_section(psfile, "Plot of actual zeros"); ps_set_pen(psfile, 0.0, 0.30, 0.0, 0.0); for (yi=0; yi= 2) return; if (za >= Zero && zb >= Zero && zc >= Zero) return; if (za <= Zero && zb <= Zero && zc <= Zero) return; if ((zc == Zero) || ((zb > Zero) != (zc > Zero))) { double t; Float s; t = xa; xa = xc; xc = t; t = ya; ya = yc; yc = t; s = za; za = zc; zc = s; } /* Now zc != 0. */ /* Also za == 0, or zb == 0, or (sign(za) != sign(zb)) */ if ((zb == Zero) || ((zb > Zero) != (zc > Zero))) { double t; Float s; t = xa; xa = xb; xb = t; t = ya; ya = yb; yb = t; s = za; za = zb; zb = s; } /* Now zb != 0, zc != 0. */ /* Also za = 0, or (sign(za) != sign(zb) and sign(za) != sign(zc)) */ if (za != Zero) { double sab = zb/(zb - za); double sba = za/(za - zb); double xab = xa*sab + xb*sba; double yab = ya*sab + yb*sba; double sac = zc/(zc - za); double sca = za/(za - zc); double xac = xa*sac + xc*sca; double yac = ya*sac + yc*sca; ps_draw_segment(psfile, xab, yab, xac, yac); } else { double sbc = zc/(zc - zb); double scb = zb/(zb - zc); double xbc = xb*sbc + xc*scb; double ybc = yb*sbc + yc*scb; assert((zb > 0) != (zc > 0), "fltzeros2_in_triangle: sign confusion"); ps_draw_segment(psfile, xa, ya, xbc, ybc); } }