next up previous contents
Next: Vector and matrix algebra Up: geom Previous: Objective C primitives   Contents

Point and line primitives

 
/* place a dot within range (-2.0, 2.0) */
/* at coordinate (x,y), color l         */

void videoadot(x,y,l) double x, y; int l; {
videodot(199-(int)(42.5*y+100.0),(int)(50.0*x+160.0),l);}

 
/* place a dot within range (-2.0, 2.0)  */
/* at coordinate (x,y), visibility l     */

void pltms(x,y,l) double x, y; int l; {int xx, yy;
xx=(int)(50.0*x);
yy=(int)(50.0*y);
if (l) videodot(yy,xx,1);
}

 
void geoms(x,y,l) double x, y; int l; {
if (l) videodot(199-(int)(42.5*y+100.0),(int)(50.0*x+160.0),l);
}

 
void geomms(x,y,l,m) double x, y; int l, m; {int xx, yy;
if (!l) return;
xx=(int)(100.0*x+320.0); if (xx<0) xx=0; if (xx>640) xx=640;
yy=199-(int)(42.5*y+100.0); if (yy<0) yy=0; if (yy>200) yy=200;
videodot(yy,xx,m);
}

/* pltil - interrupted line */

pltil(x1,z1,q1,x2,z2,q2,l) double x1, z1, q1, x2, z2, q2; int l; {
int    s1, s2;
double xm, zm;
s1=q1>0.0?l:0;
s2=q2>0.0?l:0;
if (s1!=s2) {
  xm=x1-q1*((x2-x1)/(q2-q1));
  zm=z1-q1*((z2-z1)/(q2-q1));
  pltms(xm,zm,s1);
  }
pltms(x2,z2,s2);
}



Pedro Hernandez 2004-05-13