00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 static char *id="@(#) $Id: shpers.c,v 1.2 2006/08/17 19:28:17 mhender Exp $";
00018
00019 #include <shInternal.h>
00020 #include <math.h>
00021
00032 void shpers(float *x,float *y,float *z,float *s,float *t,float *depth)
00033 {
00034 float c1,c2,c3;
00035 float dtemp;
00036
00037
00038
00039 c1= (*x-shv_x0)*shv_n11+(*y-shv_y0)*shv_n12+(*z-shv_z0)*shv_n13;
00040 c2= (*x-shv_x0)*shv_n21+(*y-shv_y0)*shv_n22+(*z-shv_z0)*shv_n23;
00041 c3= (*x-shv_x0)*shv_n31+(*y-shv_y0)*shv_n32+(*z-shv_z0)*shv_n33;
00042
00043 dtemp=(shv_l-shv_d)/(c1-shv_d);
00044 *s=dtemp*c2*shv_pcale+shv_soff;
00045 *t=dtemp*c3*shv_pcale+shv_toff;
00046 *depth=-dtemp*c1*shv_dscl+shv_doff;
00047
00048 return;
00049 }
00060 void shunpers(float *ss,float *tt,float *dd,float *xx,float *yy,float *zz)
00061 {
00062 float c1,c2,c3;
00063
00064
00065
00066 c1=shv_d*(*dd-shv_doff)/(*dd-shv_doff+shv_dscl*(shv_l-shv_d));
00067 c2=(*ss-shv_soff)*(c1-shv_d)/(shv_l-shv_d)/shv_pcale;
00068 c3=(*tt-shv_toff)*(c1-shv_d)/(shv_l-shv_d)/shv_pcale;
00069
00070 *xx=shv_x0+c1*shv_n11+c2*shv_n21+c3*shv_n31;
00071 *yy=shv_y0+c1*shv_n12+c2*shv_n22+c3*shv_n32;
00072 *zz=shv_z0+c1*shv_n13+c2*shv_n23+c3*shv_n33;
00073
00074 return;
00075 }
00076
00090 void shvw(float *dist,float *alpha,float *beta,float *xmin,float *xmax,float *ymin,float *ymax,float *zmin,float *zmax)
00091 {
00092 float a,b,pi;
00093
00094
00095
00096 shv_x0=((*xmin)+(*xmax))/2.;
00097 shv_y0=((*ymin)+(*ymax))/2.;
00098 shv_z0=((*zmin)+(*zmax))/2.;
00099
00100 pi=3.1415926;
00101 a=(*alpha-90.)*pi/180.;
00102 b=*beta*pi/180.;
00103
00104 shv_n11=cos(b)*cos(a);
00105 shv_n12=cos(b)*sin(a);
00106 shv_n13=sin(b);
00107
00108 shv_eye[0]=*dist*shv_n11;
00109 shv_eye[1]=*dist*shv_n12;
00110 shv_eye[2]=*dist*shv_n13;
00111
00112 shv_n21=-sin(a);
00113 shv_n22=cos(a);
00114 shv_n23=0.0;
00115
00116 shv_n31=-sin(b)*cos(a);
00117 shv_n32=-sin(b)*sin(a);
00118 shv_n33=cos(b);
00119
00120 shv_d=*dist;
00121 shv_l=0.75*shv_d;
00122 return;
00123 }
00124
00132 void shqeye(float *xe,float *ye,float *ze)
00133 {
00134
00135
00136
00137 *xe=shv_d*shv_n11;
00138 *ye=shv_d*shv_n12;
00139 *ze=shv_d*shv_n13;
00140 return;
00141 }
00142
00152 void shsize(float *scl,float *s0,float *t0,float *dsc,float *d0)
00153 {
00154
00155
00156
00157 shv_pcale=*scl;
00158 shv_soff=*s0;
00159 shv_toff=*t0;
00160 shv_doff=*d0;
00161 shv_dscl=*dsc;
00162
00163 return;
00164 }