src/sharrow.c

00001 
00006 /*
00007  *  PROGRAM NAME:  sh
00008  *
00009  *  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES
00010  *  CORPORATION 12/1/2001.  ALL RIGHTS RESERVED.
00011  *
00012  *  Please refer to the LICENSE file in the top directory
00013  *
00014  *      author: Mike Henderson mhender@watson.ibm.com
00015  */
00016 
00017 static char *id="@(#) $Id: sharrow.c,v 1.2 2006/08/17 19:28:17 mhender Exp $";
00018 
00019 #include <shInternal.h>
00020 #include <math.h>
00021 
00024 #define  f0(s) 1+s*s*(2*s-3)
00025 #define  f1(s) -s*s*(2*s-3)
00026 #define  f2(s) s*(s-1)*(s-1)
00027 #define  f3(s) s*s*(s-1)
00028 
00045 void sharrow(float *x0,float *y0,float *z0,int *idx0,int *idy0,float *x1,float *y1,float *z1,int *idx1,int *idy1)
00046  {
00047   int rl,gl,bl;
00048   int orl=0;
00049   int ogl=0;
00050   int obl=0;
00051   float d,dx,dy;
00052   float s0=0.;
00053   float t0=0.;
00054   float d0=0.;
00055   float s1=0.;
00056   float t1=0.;
00057   float d1=0.;
00058   int ip;
00059   int i0,j0;
00060   int i1,j1;
00061   float dx0,dy0;
00062   float dx1,dy1;
00063   float s;
00064   int i,j,io,jo;
00065   int zero=0;
00066   int one=1;
00067 
00068   shpers(x0,y0,z0,&s0,&t0,&d0);
00069   i0=floor(s0*shMax+.5);
00070   j0=floor(t0*shMax+.5);
00071 
00072   shpers(x1,y1,z1,&s1,&t1,&d1);
00073   i1=floor(s1*shMax+.5);
00074   j1=floor(t1*shMax+.5);
00075 
00076   shqlinc(&orl,&ogl,&obl);
00077 
00078   d=1./sqrt((*idx0)*(*idx0)+(*idy0)*(*idy0));
00079   dx0=(*idx0)*d;
00080   dy0=(*idy0)*d;
00081   d=1./sqrt((*idx1)*(*idx1)+(*idy1)*(*idy1));
00082   dx1=(*idx1)*d;
00083   dy1=(*idy1)*d;
00084 
00085   ip=3;
00086   for(s=0.;s<1.;s+=.01)
00087    {
00088     i=f0(s)*i0+f1(s)*i1+f2(s)*dx0+f3(s)*dx1;
00089     j=f0(s)*j0+f1(s)*j1+f2(s)*dy0+f3(s)*dy1;
00090 
00091     if(ip==2)
00092      {
00093       shlinc(&rl,&gl,&bl);
00094       shline2s(&io,&jo,&i,&j,&one,&one);
00095      }else{
00096       rl=orl;
00097       gl=ogl;
00098       bl=obl;
00099       shline2s(&io,&jo,&i,&j,&zero,&zero);
00100      }
00101     ip=2;
00102     io=i;
00103     jo=j;
00104    }
00105 
00106   rl=0;
00107   gl=0;
00108   bl=0;
00109   io=i1;
00110   jo=j1;
00111   i=i1-(*idx1)+.3*(*idy0);
00112   j=j1-(*idy0)-.3*(*idx0);
00113   shline2s(&io,&jo,&i,&j,&one,&one);
00114   rl=orl;
00115   gl=ogl;
00116   bl=obl;
00117   shline2s(&io,&jo,&i,&j,&zero,&zero);
00118 
00119   rl=0;
00120   gl=0;
00121   bl=0;
00122   i=i1-(*idx1)-.15*(*idy0);
00123   j=j1-(*idy0)+.15*(*idx0);
00124   shline2s(&io,&jo,&i,&j,&one,&one);
00125   rl=orl;
00126   gl=ogl;
00127   bl=obl;
00128   shline2s(&io,&jo,&i,&j,&zero,&zero);
00129 
00130   rl=0;
00131   gl=0;
00132   bl=0;
00133   io=i1-(*idx1)-.15*(*idy0);
00134   jo=j1-(*idy0)+.15*(*idx0);
00135   i=i1-(*idx1)+.15*(*idy0);
00136   j=j1-(*idy0)-.15*(*idx0);
00137   shline2s(&io,&jo,&i,&j,&one,&one);
00138   rl=orl;
00139   gl=ogl;
00140   bl=obl;
00141   shline2s(&io,&jo,&i,&j,&zero,&zero);
00142 
00143   return;
00144  }

Generated on Thu Aug 17 15:29:43 2006 for sh by  doxygen 1.4.6