12 #pragma init (init_object_module) 35 if (n>4 && (argv[4]!=
NIL)) range_check=1;
else range_check=0;
36 a1x=argv[0]->c.fvec.fv[0]; a1y=argv[0]->c.fvec.fv[1];
37 b1x=argv[2]->c.fvec.fv[0]; b1y=argv[2]->c.fvec.fv[1];
38 ax=argv[1]->c.fvec.fv[0]-a1x; ay=argv[1]->c.fvec.fv[1]-a1y;
39 bx=argv[3]->c.fvec.fv[0]-b1x; by=argv[3]->c.fvec.fv[1]-b1y;
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];
101 if (n==5) tolerance=
ckfltval(argv[4]);
else tolerance=0.0;
103 p1=argv[0]->c.fvec.fv;
104 fv=argv[1]->c.fvec.fv;
105 v1[0]=fv[0]-p1[0]; v1[1]=fv[1]-p1[1]; v1[2]=fv[2]-p1[2];
107 p2=argv[2]->c.fvec.fv;
108 fv=argv[3]->c.fvec.fv;
109 v2[0]=fv[0]-p2[0]; v2[1]=fv[1]-p2[1]; v2[2]=fv[2]-p2[2];
111 p2p1[0]=p2[0]-p1[0]; p2p1[1]=p2[1]-p1[1]; p2p1[2]=p2[2]-p1[2];
113 cross2=cross[0]*cross[0] + cross[1]*cross[1] + cross[2]*cross[2];
114 if (cross2<tolerance)
return(
NIL);
132 #define clipcode(x,y,z) (((x)<-(z))?1:(((x)>(z))?2:0))\ 133 + (((y)<-(z))?4:(((y)>(z))?8:0)) 146 v1=argv[0]; v2=argv[1];
152 if (c1 & c2)
return(
NIL);
155 temp = (z1+x1)/((x1-x2)-(z2-z1));
156 z = temp*(z2-z1)+z1; x = -z; y = temp*(y2-y1) + y1;}
158 temp = (z1 - x1) / ((x2-x1) - (z2-z1));
159 z = temp*(z2-z1) + z1; x = z; y = temp*(y2-y1) + y1;}
161 temp = (z1+y1) / ((y1-y2) - (z2-z1));
162 z = temp*(z2-z1) + z1; x = temp*(x2-x1) + x1; y = -z;}
164 temp = (z1-y1) / ((y2 - y1) - (z2-z1));
165 z = temp*(z2-z1) + z1; x = temp*(x2-x1) + x1; y = z;}
167 x1 = x; y1 = y; z1 = z; c1 =
clipcode(x,y,z);}
169 x2 = x; y2 = y; z2 = z; c2 =
clipcode(x,y,z);}
177 work =
cons(ctx,vpop(), work);
183 {
register int i,c,
code;
184 wc[0]=w+x; wc[1]=w-x; wc[2]=w+y; wc[3]=w-y; wc[4]=z; wc[5]=w-z;
187 if (wc[i++]<0) code += c;
197 eusfloat_t x1,y1,z1,w1, x2,y2,z2,w2, dx,dy,dz,dw, t1,t2,tt;
198 register int i,c1,c2;
202 v1=argv[0]; v2=argv[1];
205 if (vecsize(v1)>=4) w1=v1->
c.
fvec.
fv[3];
else w1=1.0;
207 if (vecsize(v2)>=4) w2=v2->
c.
fvec.
fv[3];
else w2=1.0;
210 if ((c1 & c2)>0)
return(
NIL);
213 if ((wc1[i]<0) || (wc2[i]<0)) {
214 tt = wc1[i] / (wc1[i]-wc2[i]);
215 if (wc1[i]<0) {
if (tt>t1) t1=tt;}
216 else {
if (tt<t2) t2=tt;}}
218 dx = x2-x1; dy = y2-y1; dz = z2-z1; dw = w2-w1;
220 x2 = x1+t2*dx; y2 = y1+t2*dy; z2 = z1+t2*dz; w2 = w1+t2*dw;}
222 x1 = x1+t1*dx; y1 = y1+t1*dy; z1 = z1+t1*dz; w1 = w1+t1*dw;}
232 work =
cons(ctx,vpop(), work);
249 for (n=0; n<size-1; n++) r->c.fvec.fv[n]=a->
c.
fvec.
fv[n]/w;
250 if (vecsize(r)>n) r->c.fvec.fv[size-1]=1.0;
251 r->c.fvec.length=
makeint(size-1);
273 for (i=0; i<size; i++) r->c.fvec.fv[i]=a->
c.
fvec.
fv[i];
274 r->c.fvec.fv[size]=1.0;
pointer HOMO2NORMAL(context *ctx, int n, argv)
pointer HOMO_VPCLIP(context *ctx, int n, argv)
pointer VPCLIP(context *ctx, int n, argv)
pointer cons(context *, pointer, pointer)
#define clipcode(x, y, z)
static int windowcoords(eusfloat_t x, eusfloat_t y, eusfloat_t z, eusfloat_t w, wc)
static eusfloat_t * crossproduct(eusfloat_t *a, eusfloat_t *b, eusfloat_t *r)
pointer HOMOGENIZE(context *ctx, int n, argv)
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
void add_module_initializer(char *, pointer(*)())
static eusfloat_t determinant3(eusfloat_t *a, eusfloat_t *b, eusfloat_t *c)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
pointer LINEINTERSECTION3(context *ctx, int n, argv)
pointer LINEINTERSECTION(context *ctx, int n, argv)
static void init_object_module()