12 #pragma init (init_object_module)
35 if (
n>4 && (argv[4]!=
NIL)) range_check=1;
else range_check=0;
40 abx=b1x-a1x; aby=b1y-a1y;
42 if (cz==0)
return(
NIL);
46 (u<0.0 || 1.0<u ||
v<0.0 || 1.0<
v))
return(
NIL);
73 {
return(
a[0] * b[1] * c[2] -
a[2] * b[1] * c[0] +
74 a[1] * b[2] * c[0] -
a[1] * b[0] * c[2] +
75 a[2] * b[0] * c[1] -
a[0] * b[2] * c[1]);}
79 { r[0]=
a[1] * b[2] -
a[2] * b[1];
80 r[1]=
a[2] * b[0] -
a[0] * b[2];
81 r[2]=
a[0] * b[1] -
a[1] * b[0];
102 if (
n==5) tolerance=
ckfltval(argv[4]);
else tolerance=0.0;
106 v1[0]=fv[0]-p1[0]; v1[1]=fv[1]-p1[1]; v1[2]=fv[2]-p1[2];
110 v2[0]=fv[0]-p2[0]; v2[1]=fv[1]-p2[1]; v2[2]=fv[2]-p2[2];
112 p2p1[0]=p2[0]-p1[0]; p2p1[1]=p2[1]-p1[1]; p2p1[2]=p2[2]-p1[2];
114 cross2=cross[0]*cross[0] + cross[1]*cross[1] + cross[2]*cross[2];
115 if (cross2<tolerance)
return(
NIL);
134 #define clipcode(x,y,z) (((x)<-(z))?1:(((x)>(z))?2:0))\
135 + (((y)<-(z))?4:(((y)>(z))?8:0))
148 v1=argv[0]; v2=argv[1];
154 if (c1 & c2)
return(
NIL);
157 temp = (z1+x1)/((x1-x2)-(z2-z1));
158 z = temp*(z2-z1)+z1; x = -z; y = temp*(y2-y1) + y1;}
160 temp = (z1 - x1) / ((x2-x1) - (z2-z1));
161 z = temp*(z2-z1) + z1; x = z; y = temp*(y2-y1) + y1;}
163 temp = (z1+y1) / ((y1-y2) - (z2-z1));
164 z = temp*(z2-z1) + z1; x = temp*(x2-x1) + x1; y = -z;}
166 temp = (z1-y1) / ((y2 - y1) - (z2-z1));
167 z = temp*(z2-z1) + z1; x = temp*(x2-x1) + x1; y = z;}
169 x1 = x; y1 = y; z1 = z; c1 =
clipcode(x,y,z);}
171 x2 = x; y2 = y; z2 = z; c2 =
clipcode(x,y,z);}
179 work =
cons(ctx,vpop(), work);
185 {
register int i,c,
code;
186 wc[0]=w+x; wc[1]=w-x; wc[2]=w+y; wc[3]=w-y; wc[4]=z; wc[5]=w-z;
189 if (wc[i++]<0)
code += c;
199 eusfloat_t x1,y1,z1,w1, x2,y2,z2,w2, dx,dy,dz,dw, t1,t2,tt;
200 register int i,c1,c2;
204 v1=argv[0]; v2=argv[1];
207 if (vecsize(v1)>=4) w1=v1->
c.
fvec.
fv[3];
else w1=1.0;
209 if (vecsize(v2)>=4) w2=v2->
c.
fvec.
fv[3];
else w2=1.0;
212 if ((c1 & c2)>0)
return(
NIL);
215 if ((wc1[i]<0) || (wc2[i]<0)) {
216 tt = wc1[i] / (wc1[i]-wc2[i]);
217 if (wc1[i]<0) {
if (tt>t1) t1=tt;}
218 else {
if (tt<t2) t2=tt;}}
220 dx = x2-x1; dy = y2-y1; dz = z2-z1; dw = w2-w1;
222 x2 = x1+t2*dx; y2 = y1+t2*dy; z2 = z1+t2*dz; w2 = w1+t2*dw;}
224 x1 = x1+t1*dx; y1 = y1+t1*dy; z1 = z1+t1*dz; w1 = w1+t1*dw;}
234 work =
cons(ctx,vpop(), work);
250 w=
a->c.fvec.fv[size-1];
251 for (
n=0;
n<size-1;
n++) r->c.fvec.fv[
n]=
a->c.fvec.fv[
n]/w;
252 if (vecsize(r)>
n) r->c.fvec.fv[size-1]=1.0;
253 r->c.fvec.length=
makeint(size-1);
275 for (i=0; i<size; i++) r->c.fvec.fv[i]=
a->c.fvec.fv[i];
276 r->c.fvec.fv[size]=1.0;