home *** CD-ROM | disk | FTP | other *** search
- save_res = resolution;
- resolution = 20;
- save_mat = view_mat;
- #view_mat = view_mat * scale(vector(0.2, 0.2, 0.2));
- iritstate("Coplanar", false);
-
- #
- # build nose for hammer
- #
- cylin1= cylin(vector(0, -4 , -0.1), vector(0, 0, 4.2), 8.1) * rotz( 2 );
- cylin2= cylin(vector(3.43, -4.92, -1), vector(0, 0, 6), 6) * rotz( 4 );
- #interact(list(cylin1, cylin2));
-
- nose = cylin1 - cylin2;
- free(cylin1);
- free(cylin2);
- #interact(nose);
-
- b1 = box(vector(6, -0.1, -1), -18, -18, 6);
- #interact(list(nose, b1));
-
- nose = nose - b1;
- free(b1);
- #interact(nose);
-
- b3 = box(vector(-0.1, -1, -1), -9, 6, 6);
- #interact(list(b3, nose));
-
- nose = nose - b3;
- free(b3);
- #interact(nose);
-
- body = box(vector(0.1, -0.25, -0.15), -6, 4.6, 4.3);
- #interact(list(body, nose));
-
- body = body + nose;
- free(nose);
- #interact(body);
-
- # up
- b2 = box(vector(2, 0, -1), -11, -1, 6);
- body = body - b2;
- free(b2);
- #interact(body);
-
- # down
- b2 = box(vector(2, 4, -1), -10, 2, 6);
- body = body - b2;
- free(b2);
- #interact(body);
-
- # left
- b3 = box(vector(-8, -4, 0), 20, 16, -1);
- body = body - b3;
- free(b3);
- #interact(body);
-
- # right
- b4 = box(vector(-8, -4, 4), 20, 16, 1);
- body = body - b4;
- free(b4);
- #interact(body);
-
-
- # build hole
- cylin3 = cylin(vector(3, -3, 2), vector(0, 7, 0), 0.7);
- box1 = box(vector(3, -3, 1.3), 7, 7, 1.4);
- #interact(list(cylin3,box1));
- hole1 = cylin3 + box1;
- free(cylin3);
- free(box1);
-
- body = body - hole1;
- free(hole1);
- #interact(body);
-
- # correct body
- box1 = box(vector(-5, -1, -1), -2, 6, 6);
- sph1 = sphere( vector(-4.3, 2, 2), 3 );
- hole3 = box1 - sph1;
- free(sph1);
- free(box1);
- body = body - hole3;
- free(hole3);
- #interact(body);
-
- # add conus
- cone1 = cone(vector(-9, 2, 2), vector(8, 0, 0), 2);
- body = body + cone1;
- free(cone1);
- #interact(body);
-
- #correct conus
- box4 = box(vector(-8, -1, -1), -4, 6, 6);
- cone4 = cone(vector(-7, 2, 2), vector(-7, 0, 0), 2.5);
- hole2 = box4 - cone4;
- #interact(list(body, hole2));
- free(box4);
- free(cone4);
-
- body = body - hole2;
- free(hole2);
-
- color( body, white );
- #interact(body);
-
- # Build Klin
- klin = box(vector(0, 0, 0), 2.9, 3.0, 1);
- b1 = box(vector(0, 0, 0), 5, 5, 2)*rotx(7)*trans( vector(-1, -1, 0.5));
- klin = klin - b1;
-
- b2 = box(vector(0, 0, 0), 5, 5, -2)*rotx(-7)*trans( vector(-1, -1, 0.5));
- klin = klin - b2;
-
- klin = klin*trans(vector(-4.0, 2.2, 1.5));
- color(klin, cyan);
- #interact(klin);
-
- # build handle
- # build handle bases
-
- crc0 = circle( vector(0,0,0), 2.2) * rotx(90)
- * scale(vector(1, 1, 0.7))
- * trans(vector(-2.5, -26.5, 2));
- crc1 = circle( vector(0,0,0), 2.5) * rotx(90)
- * scale(vector(1, 1, 0.7))
- * trans(vector(-2.5, -25, 2));
- crc2 = circle( vector(0,0,0), 1.5) * rotx(90)
- * scale(vector(1, 1, 0.6))
- * trans(vector(-2.5, 0, 2));
- crc3 = circle( vector(0,0,0), 1.9) * rotx(90)
- * scale(vector(1, 1, 0.6))
- * trans(vector(-2.5, 6.3, 2));
- end_crc = circle( vector(0,0,0), 0.00001 );
- handle = sFromCrvs( list( trans( vector(-2.5, -26.5, 2))*end_crc,
- crc0, crc1, crc2, crc3,
- trans( vector(-2.5, 4.4, 2))*end_crc), 3 );
- free( crc0 );
- free( crc1 );
- free( crc2 );
- free( crc3 );
- free( end_crc );
-
- #show the hammer
- #save("hammer1", list(body, handle, klin) );
- interact( list(body, handle, klin) );
-
- #
- # build nail
- #
-
- resolution = 10;
- cyl1= cylin(vector(0, 0, 2), vector(-0.5, 0, 0), 1);
- cyl2= cylin(vector(-0.48, 0, 2), vector(-10.2, 0, 0), 0.3);
- con = cone(vector(-10.5, 0, 2), vector(-1, 0, 0), 0.3);
- color(con, cyan);
- #interact( list(cyl1, cyl2, con));
-
- nail1 = cyl1 + cyl2;
- color(nail1, cyan);
- free( cyl1 );
- free( cyl2 );
- #interact( list(nail1, con) );
-
- # build matrix for the nail
- nail_mat = rotz(37)*trans(vector(-35.0, -12.0, 0));
- nail1 = nail_mat * nail1;
- con = nail_mat * con;
-
- #
- # Build wall
- #
-
- wall = box(vector(0, 0, 0), 2, 30, 20);
- wall = wall*trans(vector(-46.5,-30,-10));
- color(wall, MAGENTA);
-
- #show hammer and nail
- #save("hammer2", list(body, handle, klin, nail1, con, wall) );
- interact( list(body, handle, klin, nail1, con, wall) );
-
- # animate hammer
-
- #initialize moving matrix
- matr1 = trans(vector(0,0,0));
- matr2 = trans(vector(0,0,0));
-
- for( j=1, 1, 4,
- # move hammer to the nail
- for( i=1, 1, 35,
- matr1 = matr1*trans(vector(-0.8, 0, 0))*rotz(1):
- view( list(matr1*body, matr1*handle, matr1*klin,
- matr2*nail1, matr2*con, wall), TRUE)
- ):
-
- #move nail with hammer
- for( i=1, 1, 2,
- matr1 = matr1*trans(vector(-0.8, 0, 0))*rotz(1):
- matr2 = matr2*trans(vector(-0.8, 0, 0))*rotz(1):
- view( list(matr1*body, matr1*handle, matr1*klin,
- matr2*nail1, matr2*con, wall), TRUE)
- ):
-
- #return hammer
- for( i=1, 1, 35,
- matr1 = matr1*trans(vector(0.8, 0, 0))*rotz(-1):
- view( list(matr1*body, matr1*handle, matr1*klin,
- matr2*nail1, matr2*con, wall), TRUE)
- )
- );
-
- # Free variables
- free( handle );
- free(body);
- free(wall);
- free( con );
- free( nail1 );
- #free( nail );
-
- resolution = save_res;
- view_mat = save_mat;
-
-
-