** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: clip.cpp,v 1.1 2000/06/19 02:58:08 kevin Exp $
+** $Id: clip.cpp,v 1.7 2001/01/02 16:02:13 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
-#include "kstddef.h"
-#include "kmath.h"
+#include "ctsupport.h"
/* NAME
* double u,v Dimensions of segment
*/
-int
+bool
clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, const double v)
{
double xc1 = x1 * u;
* double u,v Size of sector
*/
-int
+bool
clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, const double v)
{
double xc1 = x1 * u;
* double t1,t2 Starting & stopping angles of clipping
*/
-int
+bool
clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2)
{
double xc1 = x1;
xform_mtx2 (rotmtx, ccx, ccy);
t1 += theta; // rotate start and stop angles
t2 += theta;
- t1 = norm_ang (t1);
- t2 = norm_ang (t2);
+ t1 = normalizeAngle (t1);
+ t2 = normalizeAngle (t2);
if (xc2 < -D_EPSILON || fabs(yc2) > F_EPSILON) {
sys_error (ERR_SEVERE, "Internal error in clip_circle\n x1=%6.2f, y1=%6.2f, x2=%6.2f, y2=%6.2f, xc2=%6.2f, yc2=%6.2f, theta=%6.2f", x1, y1, x2, y2, xc2, yc2, theta);
static int tcode (const double x, const double y, const double m, const double b, const int clip_xaxis);
-int
+bool
clip_triangle (double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis)
{
double m = v / u; // slope of triangle lines
int c2 = tcode (x2, y2, m, b, clip_xaxis);
#ifdef DEBUG
- crt_set_cpos (1,1);
- printf ("x1:%6.2f y1:%6.2f code1:%2d x2:%6.2f y2:%6.2f code2:%2d",
+ printf ("x1:%6.2f y1:%6.2f code1:%2d x2:%6.2f y2:%6.2f code2:%2d\n",
x1, y1, c1, x2, y2, c2);
#endif
while ( c1 || c2 ) {
x2=x; y2=y; c2=tcode (x2,y2,m,b,clip_xaxis);
}
#ifdef DEBUG
- crt_set_cpos (1,1);
- printf ("x1:%6.2f y1:%6.2f code1:%2d x2:%6.2f y2:%6.2f code2:%2d", x1, y1, c1, x2, y2, c2);
+ printf ("x1:%6.2f y1:%6.2f code1:%2d x2:%6.2f y2:%6.2f code2:%2d\n", x1, y1, c1, x2, y2, c2);
#endif
}
static int rectcode (double x, double y, const double rect[4]);
-int
+bool
clip_rect (double& x1, double& y1, double& x2, double& y2, const double rect[4])
{
double x = 0, y = 0;