- double cos_xy = cos (xy), sin_xy = sin (xy);
- double cos_xz = cos (xz), sin_xz = sin (xz);
- double cos_yz = cos (yz), sin_yz = sin (yz);
- double cos_xw = cos (xw), sin_xw = sin (xw);
- double cos_yw = cos (yw), sin_yw = sin (yw);
- double cos_zw = cos (zw), sin_zw = sin (zw);
-
- double ax = 1.0, ay = 0.0, az = 0.0, aw = 0.0;
- double bx = 0.0, by = 1.0, bz = 0.0, bw = 0.0;
- double cx = 0.0, cy = 0.0, cz = 1.0, cw = 0.0;
- double dx = 0.0, dy = 0.0, dz = 0.0, dw = 1.0;
-
- double _tmp0_, _tmp1_;
-
- struct point_state points [16];
- bzero (points, sizeof (points));
-
-#define mmmm (&points[0])
-#define mmmp (&points[1])
-#define mmpm (&points[2])
-#define mmpp (&points[3])
-#define mpmm (&points[4])
-#define mpmp (&points[5])
-#define mppm (&points[6])
-#define mppp (&points[7])
-#define pmmm (&points[8])
-#define pmmp (&points[9])
-#define pmpm (&points[10])
-#define pmpp (&points[11])
-#define ppmm (&points[12])
-#define ppmp (&points[13])
-#define pppm (&points[14])
-#define pppp (&points[15])
-
- while (1)
- {
- double temp_mult;
-
-#define compute(a,b,c,d,point_state) \
- temp_mult = (unit_pixels / (((a*az) + (b*bz) + (c*cz) + (d*dz) + \
- (a*aw) + (b*bw) + (c*cw) + (d*dw)) \
- - observer_z)); \
- point_state->old_x = point_state->new_x; \
- point_state->old_y = point_state->new_y; \
- point_state->new_x = ((((a*ax) + (b*bx) + (c*cx) + (d*dx)) * temp_mult) \
- + x_offset); \
- point_state->new_y = ((((a*ay) + (b*by) + (c*cy) + (d*dy)) * temp_mult) \
- + y_offset); \
- point_state->same_p = (point_state->old_x == point_state->new_x && \
- point_state->old_y == point_state->new_y);
-
- compute (-1, -1, -1, -1, mmmm);
- compute (-1, -1, -1, 1, mmmp);
- compute (-1, -1, 1, -1, mmpm);
- compute (-1, -1, 1, 1, mmpp);
- compute (-1, 1, -1, -1, mpmm);
- compute (-1, 1, -1, 1, mpmp);
- compute (-1, 1, 1, -1, mppm);
- compute (-1, 1, 1, 1, mppp);
- compute ( 1, -1, -1, -1, pmmm);
- compute ( 1, -1, -1, 1, pmmp);
- compute ( 1, -1, 1, -1, pmpm);
- compute ( 1, -1, 1, 1, pmpp);
- compute ( 1, 1, -1, -1, ppmm);
- compute ( 1, 1, -1, 1, ppmp);
- compute ( 1, 1, 1, -1, pppm);
- compute ( 1, 1, 1, 1, pppp);
-
- move_line (mmmm, mmmp, color0);
- move_line (mmmm, mmpm, color0);
- move_line (mmpm, mmpp, color0);
- move_line (mmmp, mmpp, color0);
-
- move_line (pmmm, pmmp, color1);
- move_line (pmmm, pmpm, color1);
- move_line (pmpm, pmpp, color1);
- move_line (pmmp, pmpp, color1);
-
- move_line (mpmm, mpmp, color2);
- move_line (mpmm, mppm, color2);
- move_line (mppm, mppp, color2);
- move_line (mpmp, mppp, color2);
-
- move_line (mmpp, mppp, color3);
- move_line (mmpp, pmpp, color3);
- move_line (pmpp, pppp, color3);
- move_line (mppp, pppp, color3);
-
- move_line (mmmm, mpmm, color4);
- move_line (mmmm, pmmm, color4);
- move_line (mpmm, ppmm, color4);
- move_line (pmmm, ppmm, color4);
-
- move_line (mmmp, mpmp, color5);
- move_line (mmmp, pmmp, color5);
- move_line (pmmp, ppmp, color5);
- move_line (mpmp, ppmp, color5);
-
- move_line (mmpm, mppm, color6);
- move_line (mmpm, pmpm, color6);
- move_line (pmpm, pppm, color6);
- move_line (mppm, pppm, color6);
-
- move_line (ppmm, ppmp, color7);
- move_line (ppmm, pppm, color7);
- move_line (pppm, pppp, color7);
- move_line (ppmp, pppp, color7);
-
- /* If you get error messages about the following forms, and you think you're
- using an ANSI C conforming compiler, then you're mistaken. Possibly you're
- mixing an ANSI compiler with a non-ANSI preprocessor, or vice versa.
- Regardless, your system is broken; it's not a bug in this program.
- */
-#if __STDC__ || SVR4
-# define rotate(name,dim0,dim1,cos,sin) \
- _tmp0_ = ((name##dim0 * cos) + (name##dim1 * sin)); \
- _tmp1_ = ((name##dim1 * cos) - (name##dim0 * sin)); \
- name##dim0 = _tmp0_; \
- name##dim1 = _tmp1_;
-
-# define rotates(dim0,dim1) \
- if (sin_##dim0##dim1 != 0) { \
- rotate(a, dim0, dim1, cos_##dim0##dim1, sin_##dim0##dim1); \
- rotate(b, dim0, dim1, cos_##dim0##dim1, sin_##dim0##dim1); \
- rotate(c, dim0, dim1, cos_##dim0##dim1, sin_##dim0##dim1); \
- rotate(d, dim0, dim1, cos_##dim0##dim1, sin_##dim0##dim1); \
- }
-
-#else /* !__STDC__, courtesy of Andreas Luik <luik@isa.de> */
-# define rotate(name,dim0,dim1,cos,sin) \
- _tmp0_ = ((name/**/dim0 * cos) + (name/**/dim1 * sin)); \
- _tmp1_ = ((name/**/dim1 * cos) - (name/**/dim0 * sin)); \
- name/**/dim0 = _tmp0_; \
- name/**/dim1 = _tmp1_;
-
-# define rotates(dim0,dim1) \
- if (sin_/**/dim0/**/dim1 != 0) { \
- rotate(a,dim0,dim1,cos_/**/dim0/**/dim1,sin_/**/dim0/**/dim1); \
- rotate(b,dim0,dim1,cos_/**/dim0/**/dim1,sin_/**/dim0/**/dim1); \
- rotate(c,dim0,dim1,cos_/**/dim0/**/dim1,sin_/**/dim0/**/dim1); \
- rotate(d,dim0,dim1,cos_/**/dim0/**/dim1,sin_/**/dim0/**/dim1); \
- }
-#endif /* !__STDC__ */
-
- rotates (x,y);
- rotates (x,z);
- rotates (y,z);
- rotates (x,w);
- rotates (y,w);
- rotates (z,w);
-
- XSync (dpy, True);
- if (delay) usleep (delay);
- }
-}