Programming and Graphics

(Kiana) #1

218 Introduction to C++ Programming and Graphics


xp=x[i];
yp=y[i];

if(Icheck==1) // perform crossing checks
{

if( (xp>xmax && xpp>xmax) // both points are
||(xp<xmin && xpp<xmin) // outside the plotting
||(yp>ymax && ypp>ymax) // window: move
||(yp<ymin && ypp<ymin)) // but do not draw
{
move2 (xp,yp); continue; // consider the next value of i
}

float crossxmax = (xp-xmax)*(xpp-xmax); // crossing test

if (crossxmax<tol)
{
xint = xmax-0.001;
yint = ((xint-xpp)*yp-(xint-xp)*ypp)/(xp-xpp);
if(xpp>=xmax)
{
xpp = xint; ypp = yint;
move2 (xpp,ypp);
}
else
{
xp=xint; yp=yint;
}
}

float crossxmin = (xp-xmin)*(xpp-xmin);

if (crossxmin<tol)
{
xint = xmin+0.001;
yint = ((xint-xpp)*yp-(xint-xp)*ypp)/(xp-xpp);
if(xpp<=xmin)
{
xpp = xint; ypp = yint;
move2 (xpp,ypp);
}
else
{
xp=xint; yp=yint;
}
}

float crossymax = (yp-ymax)*(ypp-ymax);
Free download pdf