def plotfunc2d(minx, maxx, n): pl = plotfunc2d2poly(minx, maxx, n) irit.color(pl, irit.YELLOW) irit.attrib(pl, "width", irit.GenRealObject(0.05)) miny = 1e+006 maxy = -1e+006 i = 0 while (i <= 2): miny = miny + i i = i + 1 retval = pl i = 0 while (i <= irit.SizeOf(pl) - 1): v = irit.coord(pl, i) real_val = irit.FetchRealObject(irit.coord(v, 1)) if (real_val > maxy): maxy = irit.FetchRealObject(irit.coord(v, 1)) if (real_val < miny): miny = irit.FetchRealObject(irit.coord(v, 1)) i = i + 1 ax = (irit.poly( irit.list((irit.min(minx, 0), 0, 0), (irit.max(maxx, 0), 0, 0)), 1) + irit.poly( irit.list((0, irit.min(miny, 0), 0), (0, irit.max(maxy, 0), 0)), 1)) irit.color(ax, irit.RED) irit.attrib(ax, "width", irit.GenRealObject(0.02)) tr = irit.trans( ((-minx + maxx) / 2.0, (-miny + maxy) / 2.0, 0)) * irit.scale( (2.0 / (maxx - minx), 2.0 / (maxy - miny), 0)) sv = irit.GetViewMatrix() irit.SetViewMatrix(irit.rotx(0)) retval = irit.list(pl, ax) * tr irit.viewobj(irit.list(irit.GetViewMatrix(), retval)) irit.printf("xdomain = [%lf %lf], ydomain = [%lf %lf]\n", irit.list(minx, maxx, miny, maxy)) irit.SetViewMatrix(sv) return retval
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # This is the DtoP custom designed Gearbox 'EndPlate' # Designed by Andy Bray <*****@*****.**> 1992 # save_mat = irit.GetViewMatrix() irit.SetViewMatrix( irit.GetViewMatrix() * irit.scale( ( 0.13, 0.13, 0.13 ) )) save_res = irit.GetResolution() cplnr = irit.iritstate( "coplanar", irit.GenIntObject(1) ) # Try 'irit.iritstate("coplanar", false);' box1 = irit.box( ( 0, 0, 1 ), 7.8, 10.4, 1.6 ) # If the line below is uncommented, then the file fails at the first operation # most other resolutions work without problem. This could be because # coincidentally something approximates colinear when it is not, but in that # case a resultion of 50 or 20 might do it, and do not. # resolution = 10; hole1 = irit.cylin( ( 1, 1, 2.601 ), ( 0, 0, (-1.6015 ) ), 0.3, 3 ) solid1 = ( box1 - hole1 ) irit.free( hole1 ) irit.free( box1 ) irit.view( irit.list( irit.GetViewMatrix(), solid1 ), irit.ON )
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Examples of constructing uniform point distributions on freeforms. # # Gershon Elber, August 1996. # save_mat = irit.GetViewMatrix() irit.SetViewMatrix( irit.rotx( 0 )) irit.viewobj( irit.GetViewMatrix() ) # # Some examples for curves. # c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 0 ), \ irit.ctlpt( irit.E2, (-1 ), 0.1 ), \ irit.ctlpt( irit.E2, (-0.9 ), (-0.1 ) ), \ irit.ctlpt( irit.E2, 0.9, 0 ) ) ) irit.color( c1, irit.MAGENTA ) pts = irit.ffptdist( c1, 0, 1000 ) e2pts = irit.nil( ) i = 1 while ( i <= irit.SizeOf( pts ) ):
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # This solid was taken from: Geometric Modeling, # by Michael E. Mortenson page 441, figure 10.9 # # Created by Gershon Elber, Apr 90 # t = irit.time(1) save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5))) save_res = irit.GetResolution() # # Try it with coplanar false for fun. # # irit.iritstate( "coplanar", false ); # psort = irit.iritstate("polysort", irit.GenRealObject(0)) t1 = irit.box(((-2), (-0.35), 0), 4, 0.7, 0.4) irit.SetResolution(80) t2 = irit.cylin((0, 0, 0), (0, 0, 0.4), 1.4, 3) s1 = t1 * t2
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # ############################################################################ # # Warping teapot using FFD trivariates. # # Gershon Elber, Sep 1999. # save_mat2 = irit.GetViewMatrix() irit.SetViewMatrix( irit.rotx( 0 )) # # Get a model of a teapot. # echosrc2 = irit.iritstate( "echosource", irit.GenRealObject(0) ) def interact( none ): irit.viewclear( ) import teapot teapotorig = irit.load( "teapot" ) def interact( none ): irit.viewdclear( ) irit.viewobj( none )
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Intersection of cone and a cylinder: # Try this one with resolution equal 20 - slower, but much nicer! # # Created by Gershon Elber, Jan. 89 # view_mat1 = irit.GetViewMatrix() * irit.sc(0.2) save_res = irit.GetResolution() irit.SetResolution(8) # ############################################################################ cone1 = irit.con2((0, 0, (-1)), (0, 0, 4), 2, 1, 3) cylin1 = irit.cylin((0, 3, 0), (0, (-6), 2), 0.7, 3) a = (cone1 + cylin1) irit.free(cylin1) irit.free(cone1) irit.interact(irit.list(view_mat1, a)) # # Currently variables can not be introduced in a loop (except the iteration # variable), so we prepare all variables in advance. #
pts = irit.nil( ) i = 0 while ( i <= 1000 ): p = irit.point( irit.random( (-0.5 ), 0.5 ), irit.random( (-0.5 ), 0.5 ), 0 ) if ( irit.FetchRealObject(irit.ppinclude( pl1, irit.Fetch3TupleObject(p) ) ) ): irit.color( p, irit.GREEN ) else: irit.color( p, irit.RED ) irit.snoc( p * irit.tx( 0 ), pts ) i = i + 1 irit.interact( irit.list( view_mat0, pl1, pts ) ) irit.save( "pt_inpl1", irit.list( irit.GetViewMatrix(), pl1, pts ) ) irit.free( pl1 ) # ############################################################################# # # Point inclusion in a curve: # crv1 = irit.cbspline( 4, irit.list( ( 0, 0, 0 ), ( 0.3, 0, 0 ), irit.point( 0.3, 0.1, 0 ), irit.point( 0.2, 0.1, 0 ), irit.point( 0.2, 0.5, 0 ), irit.point( 0.3, 0.5, 0 ), irit.point( 0.3, 0.6, 0 ), irit.point( 0, 0.6, 0 ), irit.point( 0, 0.5, 0 ), irit.point( 0.1, 0.5, 0 ), irit.point( 0.1, 0.1, 0 ), irit.point( 0, 0.1, 0 ) ), irit.list( irit.KV_PERIODIC ) ) * irit.tx( (-0.15 ) ) * irit.ty( (-0.3 ) ) irit.view( irit.list( irit.GetAxes(), crv1 ), irit.ON ) pts = irit.nil( ) i = 0 while ( i <= 1000 ):
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Manual construction of layout (prisa) of simple polyhedra. # save_mat = irit.GetViewMatrix() square = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1, 1, 0 ), ( 1, 0, 0 ), ( 0, 0, 0 ) ), irit.TRUE ) irit.attrib( square, "width", irit.GenStrObject("0.02" )) irit.color( square, irit.RED ) rectan = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 2, 1, 0 ), ( 2, 0, 0 ), ( 0, 0, 0 ) ), irit.TRUE ) irit.attrib( rectan, "width", irit.GenStrObject("0.02" )) irit.color( rectan, irit.RED ) triang = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1.5, 0.5, 0 ), ( 0, 0, 0 ) ), irit.TRUE ) irit.attrib( triang, "width", irit.GenStrObject("0.02" )) irit.color( triang, irit.RED ) irit.SetViewMatrix( irit.scale( ( 0.2, 0.2, 0.2 ) )) cube_prisa = irit.list( square, square * irit.trans( ( 1, 0, 0 ) ), square * irit.trans( ( 2, 0, 0 ) ), square * irit.trans( ( (-1 ), 0, 0 ) ), square * irit.trans( ( 0, 1, 0 ) ),
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Simple (and not so simple) 3D puzzles animated using animation curves. # # Gershon Elber, January 1994 # save_mat = irit.GetViewMatrix() # ############################################################################ # StickStar # sqrt2 = math.sqrt(2) eps = 0.015 rad = 0.3 len = (rad + eps) * 2 itemaux1 = irit.box( ((-rad) / sqrt2, (-rad) / sqrt2, (-len)), rad * 2 / sqrt2, rad * 2 / sqrt2, len * 2) * irit.rz(45) itemaux2 = ( itemaux1 * irit.tx(rad) - itemaux1 * irit.rotx(90) * irit.tz(rad + eps) - itemaux1 * irit.rotx(90) * irit.tz((-rad) - eps)) * irit.tx(eps / 2) diag = (len + eps) diagpoly = irit.poly( irit.list((diag, diag, 0), ((-diag), diag, 0), ((-diag), 0, diag), (diag, 0, diag)), irit.FALSE)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Extrusion example of the IRIT letters created manually: # # Created by Gershon Elber, Mar 89 # save_mat = irit.GetViewMatrix() save_res = irit.GetResolution() irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale(((-1), 1, 1))) v1 = (0, 0, 0) # The I letter v2 = (0.3, 0, 0) v3 = (0.3, 0.1, 0) v4 = (0.2, 0.1, 0) v5 = (0.2, 0.5, 0) v6 = (0.3, 0.5, 0) v7 = (0.3, 0.6, 0) v8 = (0, 0.6, 0) v9 = (0, 0.5, 0) v10 = (0.1, 0.5, 0) v11 = (0.1, 0.1, 0) v12 = (0, 0.1, 0)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Display of all primitives of the system: # BOX, GBOX, CONE, CYLIN, SPHERE, TORUS # # Created by Gershon Elber, Dec. 88 # save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5))) axes15 = irit.GetAxes() * irit.scale((1.5, 1.5, 1.5)) # # Create primitive as approximated integral polynomial surfaces. # save_prim_rat_srfs = irit.iritstate("primratsrfs", irit.GenRealObject(0)) cyls = irit.list(irit.cylin(((-0.8), 0, 0), ((-0.5), 0.3, 0.3), 0.3, 0), irit.cylin((0.8, 0, 0), (0.8, 0, 0), 0.3, 1), irit.cylin((0, (-0.8), 0), (0.1, (-0.5), 0.2), 0.3, 3), irit.cylin((0, 0.8, 0), (0, 0.8, 0), 0.3, 2), irit.cylin((0, 0, (-0.8)), (0.4, 0.2, (-0.5)), 0.3, 3), irit.cylin((0, 0, 0.8), (0, 0, 0.8), 0.3, 1)) irit.color(cyls, irit.RED) cones = irit.list(irit.cone(((-0.5), 0, 0), ((-0.5), 0, 0), 0.5, 0),
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Routines to test the boolean operations among geometric objects: # # Intersection between a box and a cylinder - make a hole in the box # b = irit.box( ( (-3 ), (-2 ), (-1 ) ), 6, 4, 2 ) c = irit.cylin( ( 0, 0, (-4 ) ), ( 0, 0, 8 ), 1, 3 ) save_view = irit.GetViewMatrix() irit.SetViewMatrix( irit.GetViewMatrix() * irit.scale( ( 0.1, 0.1, 0.1 ) )) a1 = ( b + c ) irit.interact( irit.list( irit.GetViewMatrix(), a1 ) ) a2 = b * c irit.interact( a2 ) a3 = ( b - c ) irit.interact( a3 ) c = ( irit.con2( ( 0, 0, 0 ), ( 0, 0, 28 ), 17, 12, 3 ) - irit.con2( ( 0, 0, (-1 ) ), ( 0, 0, 30 ), 14, 9, 3 ) ) a4 = ( c - irit.box( ( (-50 ), (-50 ), (-1 ) ), 100, 100, 28 ) ) irit.save( "closloop", irit.list( a1, a2, a3, a4 ) )
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Conic section's constructor. # # Gershon Elber, 1998 # save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.sc(0.7)) circ1 = irit.conicsec( irit.list( 1, 0, 1, 0, 0, (-1.2 ) ),\ 0.1, 0, 0 ) circ2 = irit.conicsec( irit.list( 1, 0, 1, 0, (-0.5 ), (-1 ) ),\ 0, 0, 0 ) irit.color(circ1, irit.WHITE) irit.color(circ2, irit.YELLOW) elp1 = irit.conicsec( irit.list( 1, 2, 4, 0.5, 2, (-0.2 ) ),\ 0, 0, 0 ) elp2 = irit.conicsec( irit.list( 1, 0, 4, 0, 0, (-1 ) ),\ (-0.1 ), 0, 0 ) irit.color(elp1, irit.RED) irit.color(elp2, irit.MAGENTA) hyp1 = irit.conicsec( irit.list( (-1 ), 2, 4, 0.5, 2, (-0.2 ) ),\ 0, 0, 0 )
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Some examples to manipulation of text in IRIT. # # Gershon Elber, May 1996. # save_mat = irit.GetViewMatrix() def textgeom3daux(ply, wdth, dpth): retval = irit.nil() if (irit.ThisObject(ply) == irit.CURVE_TYPE): retval = irit.extrude((-ply), (0, 0, dpth), 0) if (irit.ThisObject(ply) == irit.POLY_TYPE): retval = irit.extrude( irit.ruledsrf( irit.offset(ply, irit.GenRealObject(-wdth / 2.0), 0, 0), irit.offset(ply, irit.GenRealObject(wdth / 2.0), 0, 0)), (0, 0, dpth), 3) return retval def textgeom3d(txt, wdth, dpth): retval = 1 return retval
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Example of polygonal decimation algorithm. # # Gershon Elber, June 1996. # echosrc = irit.iritstate("echosource", irit.GenIntObject(0)) save_mat = irit.GetViewMatrix() save_res = irit.GetResolution() body = irit.sbspline( 4, 4, irit.list( irit.list( irit.ctlpt( irit.E3, 1.4, 2.25, 0 ), \ irit.ctlpt( irit.E3, 1.3375, 2.38125, 0 ), \ irit.ctlpt( irit.E3, 1.4375, 2.38125, 0 ), \ irit.ctlpt( irit.E3, 1.5, 2.25, 0 ), \ irit.ctlpt( irit.E3, 1.75, 1.725, 0 ), \ irit.ctlpt( irit.E3, 2, 1.2, 0 ), \ irit.ctlpt( irit.E3, 2, 0.75, 0 ), \ irit.ctlpt( irit.E3, 2, 0.3, 0 ), \ irit.ctlpt( irit.E3, 1.5, 0.075, 0 ), \ irit.ctlpt( irit.E3, 1.5, 0, 0 ) ), irit.list( \ irit.ctlpt( irit.E3, 1.4, 2.25, 0.784 ), \ irit.ctlpt( irit.E3, 1.3375, 2.38125, 0.749 ), \ irit.ctlpt( irit.E3, 1.4375, 2.38125, 0.805 ), \ irit.ctlpt( irit.E3, 1.5, 2.25, 0.84 ), \ irit.ctlpt( irit.E3, 1.75, 1.725, 0.98 ), \
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Intersection of cone and a cylinder: # Try this one with resolution equal 20 - slower, but much nicer! # # Created by Gershon Elber, Jan. 89 # save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.2, 0.2, 0.2))) save_res = irit.GetResolution() irit.SetResolution(8) cone1 = irit.cone((0, 0, (-1)), (0, 0, 4), 2, 3) cylin1 = irit.cylin((0, 3, 1), (0, (-6), 0), 0.7, 3) a1 = (cone1 + cylin1) irit.interact(irit.list(irit.GetViewMatrix(), a1)) a2 = cone1 * cylin1 irit.interact(a2) a3 = (cone1 - cylin1) irit.interact(a3)
irit.attrib(cap, "stexture_func", irit.GenStrObject("sqrt")) irit.attrib(cap, "stexture_bound", irit.GenStrObject("-5.0 20.0")) irit.color(spout, irit.BLUE) irit.attrib(spout, "stexture", irit.smean(spout, 0)) irit.attrib(spout, "stexture_func", irit.GenStrObject("sqrt")) irit.attrib(spout, "stexture_bound", irit.GenStrObject("-5.0 20.0")) irit.color(handle, irit.MAGENTA) irit.attrib(handle, "stexture", irit.smean(handle, 0)) irit.attrib(handle, "stexture_func", irit.GenStrObject("sqrt")) irit.attrib(handle, "stexture_bound", irit.GenStrObject("-5.0 20.0")) teapot = irit.list(body, spout, handle, cap) irit.interact(irit.list(irit.GetViewMatrix(), teapot)) irit.save("meanstea", teapot) # # Render the following using irender to get the curvature bound as color map # on top of the teapot. # irit.color(body, irit.RED) irit.attrib(body, "stexture", irit.sgauss(body, 0)) irit.attrib(body, "stexture_bound", irit.GenStrObject("-5.0 10.0")) irit.color(cap, irit.GREEN) irit.attrib(cap, "stexture", irit.sgauss(cap, 0)) irit.attrib(cap, "stexture_bound", irit.GenStrObject("-5.0 10.0")) irit.color(spout, irit.BLUE)
# Gershon Elber, July 1992. # # render with raysahde with a unit matrix and the following: # # eyep 10 8 6 # lookp 0 0 0 # up 0 0 1 # fov 12 # # light 0.8 directional 0 0 1 # light 0.7 directional 0 1 0 # light 0.6 directional 1 0 0 # save_res = irit.GetResolution() irit.view(irit.list(irit.GetViewMatrix()), irit.ON) if (irit.GetMachine() == irit.MSDOS): irit.SetResolution(7) else: irit.SetResolution(10) if (irit.GetMachine() == irit.MSDOS): step = 0.2 else: step = 0.05 baselvl = (-0.72) basexymin = (-1.4) v1 = ((-16), (-16), baselvl) v2 = ((-16), 16, baselvl)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Simple molecule - 8 atoms connected as a cube. # t = irit.time( 1 ) save_res = irit.GetResolution() save_view = irit.GetViewMatrix() irit.SetViewMatrix( irit.GetViewMatrix() * \ irit.scale( ( 0.6, 0.6, 0.6 ) ) * \ irit.rotx( 20 ) * \ irit.roty( 45 ) * \ irit.trans( ( (-0.3 ), 0.2, 0 ) )) irit.SetResolution( 16) s1 = irit.sphere( ( 0, 0, 0 ), 0.2 ) s2 = irit.sphere( ( 1, 0, 0 ), 0.2 ) irit.SetResolution( 8) c1 = irit.cylin( ( 0, 0, 0 ), ( 1, 0, 0 ), 0.05, 3 ) irit.view( irit.list( irit.GetViewMatrix(), s1, s2, c1 ), irit.ON )
irit.ty( (-0.1 ) ) * \ irit.sx( 1.2 ) * \ irit.tz( 25 ), c * \ irit.ty( (-0.1 ) ) * \ irit.sc( 0.001 ) * \ irit.tz( 25 ) ), 3, irit.KV_OPEN ) irit.attrib( s2, "ptexture", irit.GenStrObject("snake2.gif,1,5" )) eyes = irit.list( irit.sphere( ( 0.42, (-0.35 ), 24.5 ), 0.1 ), irit.sphere( ( (-0.42 ), (-0.35 ), 24.5 ), 0.1 ) ) irit.color( eyes, irit.BLACK ) retval = irit.list( s1, s2, eyes ) * irit.rx( (-90 ) ) * irit.tz( 0.261 ) return retval view_mat_snake = irit.GetViewMatrix() * \ irit.sc( 0.08 ) * \ irit.tx( (-1.2 ) ) * \ irit.ty( 0.8 ) * \ irit.tz( (-0.5 ) ) snake = irit.list( snaket( 2 ) ) irit.attrprop( snake, "u_resolution", irit.GenRealObject(0.2 )) irit.interact( irit.list( view_mat_snake, xyplane, snake ) ) irit.save( "snake", irit.list( view_mat_snake, xyplane, snaket( 2 ) ) ) irit.view( irit.list( xyplane, view_mat_snake ), irit.ON ) bg_obj = irit.list( xyplane, view_mat_snake ) t = 0 while ( t <= 4 * math.pi ):
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # More examples of animated 3d bisector computations of 3-space crv and pt. # # Gershon Elber, August 1996. # speed = 5 filecount = 1000 irit.SetViewMatrix(irit.GetViewMatrix() * irit.sc(0.4)) irit.viewobj(irit.GetViewMatrix()) irit.viewstate("depthcue", 0) def polesfree(srf, dpth, tmin, tmax): retval = irit.nil() return retval def polesfree(srf, dpth, tmin, tmax): if (irit.ffpoles(srf) == 0): retval = irit.list(srf) else: if (dpth <= 0):
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # This file existance is justified to demonstrate loops on free form trans.: # save_mat = irit.GetViewMatrix() irit.SetViewMatrix( irit.GetViewMatrix() * irit.scale( ( 0.7, 0.7, 0.7 ) ) ) cbzr = irit.cbezier( irit.list( irit.ctlpt( irit.P3, 1, 0, 0, 0 ), \ irit.ctlpt( irit.P3, 0.707, 0.707, 0, 0 ), \ irit.ctlpt( irit.P3, 1, 1, 1, 0 ) ) ) sbzr = irit.sbezier( irit.list( irit.list( irit.ctlpt( irit.E3, 0, 0, 0.5 ), \ irit.ctlpt( irit.E3, 0, 0.5, (-1 ) ), \ irit.ctlpt( irit.E3, 0, 1, 0.5 ) ), irit.list( \ irit.ctlpt( irit.E3, 0.5, 0, (-0.5 ) ), \ irit.ctlpt( irit.E3, 0.5, 0.5, 1 ), \ irit.ctlpt( irit.E3, 0.5, 1, (-0.5 ) ) ), irit.list( \ irit.ctlpt( irit.E3, 1, 0, 0.5 ), \ irit.ctlpt( irit.E3, 1, 0.5, (-1 ) ), \ irit.ctlpt( irit.E3, 1, 1, 0.5 ) ) ) ) rot10x = irit.rotx( 10 ) rot10y = irit.roty( 10 ) rot10z = irit.rotz( 10 )
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Yet another simple 3D mechanical object. # # Created by Gershon Elber, Sep 89 # save_mat = irit.GetViewMatrix() save_res = irit.GetResolution() irit.SetResolution(16) irit.SetViewMatrix(irit.GetViewMatrix() * irit.trans( (0, (-0.3), 0)) * irit.scale((0.8, 0.8, 0.8))) b1 = irit.box(((-0.6), (-0.3), 0), 1.2, 0.6, 0.6) c1 = irit.cylin((0, (-0.25), 0.59), (0, 0.5, 0), 0.55, 3) s1 = (b1 + c1) irit.color(s1, irit.YELLOW) irit.free(b1) irit.free(c1) irit.view(irit.list(irit.GetViewMatrix(), s1), irit.ON) b2 = irit.box(((-0.4), (-0.4), (-0.1)), 0.8, 0.8, 0.35) irit.view(b2, irit.OFF) s2 = (s1 - b2) irit.free(s1) irit.free(b2)
# # # A model of the B58 Bomber. # # # Gershon Elber, October 1991. # if ( irit.GetMachine() == irit.MSDOS ): irit.SetResolution(8) else: irit.SetResolution(10) save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.GetViewMatrix() * irit.trans( ( 5, 2, 0 ) ) * irit.scale( ( 0.15, 0.15, 0.15 ) ) ) # # Set up for colored or wood texture version. set do_texture to 1 for # wood version, otherwise color version. Note locally (in irit) it will # always be displayed in colors. # do_texture = 0 if ( do_texture == 1 ): woodcolor = "244,164,96" texture = "wood,1" redcolor = woodcolor
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Model from "Partitioning Polyhedral Objects into Nonintersecting parts' # by mark Segal and Carlo H. Sequin, IEE CG&A, January 1988, pp 53-67. # save_mat = irit.GetViewMatrix() b1 = irit.box((0.2, 0.2, 0.2), 0.8, 0.8, 0.8) b2 = irit.box((0.2, 0.2, (-0.2)), 0.8, 0.8, (-0.8)) b3 = irit.box((0.2, (-0.2), 0.2), 0.8, (-0.8), 0.8) b4 = irit.box((0.2, (-0.2), (-0.2)), 0.8, (-0.8), (-0.8)) b5 = irit.box(((-0.2), 0.2, 0.2), (-0.8), 0.8, 0.8) b6 = irit.box(((-0.2), 0.2, (-0.2)), (-0.8), 0.8, (-0.8)) b7 = irit.box(((-0.2), (-0.2), 0.2), (-0.8), (-0.8), 0.8) b8 = irit.box(((-0.2), (-0.2), (-0.2)), (-0.8), (-0.8), (-0.8)) cubes = b1 ^ b2 ^ b3 ^ b4 ^ b5 ^ b6 ^ b7 ^ b8 irit.free(b1) irit.free(b2) irit.free(b3) irit.free(b4) irit.free(b5) irit.free(b6) irit.free(b7) irit.free(b8)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Self and partial intersections' examples # # Gershon Elber, October 1995. # save_mat = irit.GetViewMatrix() save_res = irit.GetResolution() ri = irit.iritstate("randominit", irit.GenRealObject(1960)) # Seed-initiate the randomizer, irit.free(ri) # ############################################################################ def evalantipodalptsoncrv(crv): aps = irit.antipodal(crv, 0.001, (-1e-010)) irit.printf("%d antipodal points detected\n", irit.list(irit.SizeOf(aps))) retval = irit.nil() diam = 0 i = 1 while (i <= irit.SizeOf(aps)): ap = irit.nth(aps, i) t1 = irit.coord(ap, 1)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Some examples of 3d alpha-sector computations of 3-space freeform curves. # # Gershon Elber, October 1998. # # # Set states. # save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.GetViewMatrix() * irit.sc(0.35)) irit.viewobj(irit.GetViewMatrix()) # Faster product using Bezier decomposition. iprod = irit.iritstate("bspprodmethod", irit.GenIntObject(0)) # ############################################################################ # # A point and a line in the XY plane # c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-0.3 ), (-1 ) ), \ irit.ctlpt( irit.E2, (-0.3 ), 1 ) ) ) pt2 = irit.point(0.4, 0.2, 0) irit.color(c1, irit.RED) irit.adwidth(c1, 3)
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Some examples of 2-d bisector computations. # # Gershon Elber, August 1996. # save_res = irit.GetResolution() view_mat3d = irit.GetViewMatrix() view_mat2d = irit.sc( 0.6 ) irit.viewstate( "widthlines", 1 ) pl = irit.list( irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1, 1, 0 ), ( 1, 0, 0 ) ), 0 ), irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1, 1, 0 ), ( 1, 0, 0 ), ( 0, 0, 0 ) ), 1 ),
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Intersection of two boxes: # # Created by Gershon Elber, Jan. 89 # save_mat = irit.GetViewMatrix() irit.SetViewMatrix(save_mat * irit.scale((0.15, 0.15, 0.15))) b1 = irit.box(((-3), (-2), (-1)), 6, 4, 2) b2 = irit.box(((-4), (-3), (-2)), 2, 2, 4) a1 = (b2 + b1) irit.interact(irit.list(irit.GetViewMatrix(), a1)) a2 = b2 * b1 irit.interact(a2) a3 = (b2 - b1) irit.interact(a3) a4 = (b1 - b2) irit.interact(a4) icrv = irit.iritstate("intercrv", irit.GenIntObject(1)) a5 = b2 * b1
irit.free(pt2) irit.free(mov_xyz1) irit.free(mov_xyz2) irit.free(all) # ############################################################################ # # A sphere centered at the origin # s = irit.spheresrf(1.1) d = irit.duality(s) irit.color(d, irit.YELLOW) view_mat1 = irit.GetViewMatrix() * irit.sc(0.5) irit.interact(irit.list(s, d, irit.GetAxes(), view_mat1)) # # A sphere tangent to the origin # s = irit.spheresrf(1) * irit.tx(1) d = irit.duality(s) irit.color(d, irit.YELLOW) view_mat1 = irit.GetViewMatrix() * irit.sc(0.5) * irit.tx(0.3) * irit.ty(0.3) irit.interact(irit.list(s, d, irit.GetAxes(), view_mat1)) # # A sphere not centered at the origin