def ant(scl): save_res = irit.GetResolution() bodyall = antbody() body = irit.nth(bodyall, 1) eyes = irit.nth(bodyall, 2) leg = antleg() llegs = irit.list( leg * irit.sc(1.1) * irit.sx(1.3) * irit.ry((-45)) * irit.trans( (0.1, 0, 1.02)), leg * irit.sc(1.3) * irit.ry(10) * irit.trans((0.1, 0.05, 1)), leg * irit.sc(1.2) * irit.sx(1.4) * irit.ry(40) * irit.trans( (0.1, 0.02, 0.95))) irit.SetResolution(20) irit.attrprop(llegs, "u_resolution", irit.GenRealObject(0.2)) antennas = irit.list( antantenna() * irit.ry((-110)) * irit.trans(((-0.02), 0.2, 1.6)), antantenna() * irit.ry((-70)) * irit.trans((0.02, 0.2, 1.6))) irit.attrprop(antennas, "u_resolution", irit.GenRealObject(0.2)) body = (body + irit.gpolygon(llegs, 1) + irit.gpolygon(llegs, 1) * irit.sx( (-1)) + irit.gpolygon(antennas, 1)) irit.attrib(body, "rgb", irit.GenStrObject("255,50,50")) irit.SetResolution(save_res) retval = irit.list( body, eyes) * irit.sz(1.3) * irit.sc(1) * irit.ty(0.28785) * irit.rx(90) return retval
def antanim(scl): save_res = irit.GetResolution() bodyall = antbody() body = irit.nth(bodyall, 1) eyes = irit.nth(bodyall, 2) llegs = irit.list( antlleganim(1) * irit.sc(1.1) * irit.sx(1.3) * irit.ry( (-45)) * irit.trans((0.1, 0, 1.02)), antlleganim((-1)) * irit.sc(1.3) * irit.ry(10) * irit.trans( (0.1, 0.05, 1)), antlleganim(1) * irit.sc(1.2) * irit.sx(1.4) * irit.ry(40) * irit.trans((0.1, 0.02, 0.95))) rlegs = irit.list( antrleganim( (-1)) * irit.sc(1.1) * irit.sx(1.3) * irit.ry(45) * irit.trans( ((-0.1), 0, 1.02)), antrleganim(1) * irit.sc(1.3) * irit.ry((-10)) * irit.trans( ((-0.1), 0.05, 1)), antrleganim((-1)) * irit.sc(1.2) * irit.sx(1.4) * irit.ry( (-40)) * irit.trans(((-0.1), 0.02, 0.95))) irit.SetResolution(20) antennas = irit.list( antantenna() * irit.ry((-110)) * irit.trans(((-0.02), 0.2, 1.6)), antantenna() * irit.ry((-70)) * irit.trans((0.02, 0.2, 1.6))) irit.attrprop(antennas, "u_resolution", irit.GenRealObject(0.2)) body = (body + irit.gpolygon(antennas, 1)) irit.attrib(body, "rgb", irit.GenStrObject("255,50,50")) irit.SetResolution(save_res) retval = irit.list( body, llegs, rlegs, eyes) * irit.sz(1.3) * irit.sc(1) * irit.ty(0.28785) * irit.rx(90) mov_y = irit.creparam( irit.ctlpt( irit.E1, 0 ) + \ irit.ctlpt( irit.E1, (-1 ) ), 0, 1.2 ) irit.attrib(retval, "animation", mov_y) return retval
def rook(s, clr): rookbase = (-irit.surfprev( ( irit.ctlpt( irit.E2, 0.001, 0.55 ) + \ irit.ctlpt( irit.E2, 0.11, 0.55 ) + \ irit.ctlpt( irit.E2, 0.11, 0.63 ) + \ irit.ctlpt( irit.E2, 0.13, 0.63 ) + irit.cbspline( 3, irit.list( \ irit.ctlpt( irit.E2, 0.13, 0.53 ), \ irit.ctlpt( irit.E2, 0.05, 0.51 ), \ irit.ctlpt( irit.E2, 0.07, 0.29 ), \ irit.ctlpt( irit.E2, 0.18, 0.12 ), \ irit.ctlpt( irit.E2, 0.18, 0 ) ), irit.list( irit.KV_OPEN ) ) ) * irit.rx( 90 ) ) ) axs = irit.crefine( irit.creparam( irit.pcircle( ( 0, 0, 0 ), 1 ), 0, 1 ),\ 0, irit.list( 0.05, 0.1, 0.15, 0.2, 0.3, 0.35,\ 0.4, 0.45, 0.55, 0.6, 0.65, 0.7,\ 0.8, 0.85, 0.9, 0.95 ) ) scl = irit.cbspline( 2, irit.list( \ irit.ctlpt( irit.E2, 0, 0.01 ), \ irit.ctlpt( irit.E2, 0.5, 0.01 ), \ irit.ctlpt( irit.E2, 0.5, 1 ), \ irit.ctlpt( irit.E2, 1, 1 ), \ irit.ctlpt( irit.E2, 0, 0.01 ) ), irit.list( 0, 0, 0.7, 0.701, 1.999, 2,\ 3 ) ) scl = irit.creparam( scl + scl * irit.tx( 1 ) + scl * irit.tx( 2 ) + scl * irit.tx( 3 ) + scl * irit.tx( 4 ) + scl * irit.tx( 5 ) + \ irit.ctlpt( irit.E2, 6, 0.01 ), 0, 1 ) rookwall = irit.swpsclsrf( \ irit.ctlpt( irit.E2, (-0.08 ), 0 ) + \ irit.ctlpt( irit.E2, 0.08, 0 ) + \ irit.ctlpt( irit.E2, 0.08, 0.6 ) + \ irit.ctlpt( irit.E2, (-0.08 ), 0.6 ) + \ irit.ctlpt( irit.E2, (-0.08 ), 0 ), axs, scl, irit.point( 0, 0, 1 ), 2 ) * irit.sc( 0.12 ) * irit.tz( 0.63 ) irit.attrib(rookwall, "rgb", irit.GenStrObject("255,255,100")) irit.attrib(rookbase, "rgb", irit.GenStrObject(clr)) retval = irit.list(rookbase, rookwall) * irit.sc(s) return retval
def plotfunc3d(minx, maxx, miny, maxy, n, m): pl = plotfunc3d2poly(minx, maxx, miny, maxy, n, m) irit.color(pl, irit.YELLOW) irit.attrib(pl, "width", irit.GenRealObject(0.05)) minz = 1e+006 maxz = (-1e+006) i = 0 while (i <= irit.SizeOf(pl) - 1): p = irit.coord(pl, i) j = 0 while (j <= irit.SizeOf(p) - 1): v = irit.coord(p, i) if (irit.FetchRealObject(irit.coord(v, 2)) > maxz): maxz = irit.FetchRealObject(irit.coord(v, 2)) if (irit.FetchRealObject(irit.coord(v, 2)) < minz): minz = irit.FetchRealObject(irit.coord(v, 2)) j = j + 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.poly( irit.list((0, 0, irit.min(minz, 0)), (0, 0, irit.max(maxz, 0))), 1)) irit.color(ax, irit.RED) irit.attrib(ax, "width", irit.GenRealObject(0.02)) retval = irit.list(pl, ax) irit.viewobj(retval) irit.printf( "xdomain = [%lf %lf], ydomain = [%lf %lf], zdomain = [%lf %lf]\n", irit.list(minx, maxx, miny, maxy, minz, maxz)) return retval
def dominos(path, scl, piecetimestep): retval = irit.nil() animtime = 0 dominopiece = irit.box( (-0.01, -0.006, 0), 0.02, 0.006, 0.05) * irit.sc(scl) rot_x = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 80 ) ) ) crvdomain = irit.pdomain(path) t = irit.FetchRealObject(irit.nth(crvdomain, 1)) dpath = irit.cderive(path) while (t < irit.FetchRealObject(irit.nth(crvdomain, 2))): d = irit.Fetch3TupleObject( irit.coerce(irit.ceval(dpath, t), irit.POINT_TYPE)) dlen = math.sqrt(DotProd(d, d)) rot_x = irit.creparam(rot_x, animtime, animtime + piecetimestep) irit.attrib(dominopiece, "animation", irit.list(rot_x)) irit.setname(irit.getattr(dominopiece, "animation"), 0, "rot_x") dp = dominopiece * irit.rz( -math.atan2(d[0], d[1]) * 180 / math.pi) * irit.trans( irit.Fetch3TupleObject( irit.coerce(irit.ceval(path, t), irit.VECTOR_TYPE))) irit.snoc(dp, retval) t = t + 0.04 * scl / dlen animtime = animtime + piecetimestep * 0.6 return retval
def bishop(s, clr): retval = (-irit.surfprev( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0.0001, 0.82 ), \ irit.ctlpt( irit.E2, 0.028, 0.82 ), \ irit.ctlpt( irit.E2, 0.028, 0.77 ), \ irit.ctlpt( irit.E2, 0.01, 0.77 ), \ irit.ctlpt( irit.E2, 0.01, 0.765 ), \ irit.ctlpt( irit.E2, 0.06, 0.76 ), \ irit.ctlpt( irit.E2, 0.09, 0.69 ), \ irit.ctlpt( irit.E2, 0.06, 0.625 ), \ irit.ctlpt( irit.E2, 0.02, 0.62 ), \ irit.ctlpt( irit.E2, 0.02, 0.61 ), \ irit.ctlpt( irit.E2, 0.08, 0.6 ), \ irit.ctlpt( irit.E2, 0.08, 0.59 ), \ irit.ctlpt( irit.E2, 0.03, 0.58 ), \ irit.ctlpt( irit.E2, 0.03, 0.56 ), \ irit.ctlpt( irit.E2, 0.12, 0.55 ), \ irit.ctlpt( irit.E2, 0.12, 0.53 ), \ irit.ctlpt( irit.E2, 0.05, 0.51 ), \ irit.ctlpt( irit.E2, 0.07, 0.29 ), \ irit.ctlpt( irit.E2, 0.18, 0.12 ), \ irit.ctlpt( irit.E2, 0.18, 0 ) ), irit.list( irit.KV_OPEN ) ) * irit.rx( 90 ) ) ) * irit.sc( s ) bishoptop = irit.sregion(retval, irit.ROW, 0, 0.1) bishopbody = irit.sregion(retval, irit.ROW, 0.1, 1) irit.attrib(bishoptop, "rgb", irit.GenStrObject("255,255,100")) irit.attrib(bishopbody, "rgb", irit.GenStrObject(clr)) retval = irit.list(bishopbody, bishoptop) return retval
def computeparaboliclines(s): retval = irit.sparabolc(s, 1) irit.adwidth(retval, 2) irit.awidth(retval, 0.01) irit.attrib(retval, "gray", irit.GenRealObject(0.5)) irit.attrib(retval, "rgb", irit.GenStrObject("100,255,255")) return retval
def intercrvspaint(crvs): retval = irit.nil() i = 1 while (i <= irit.SizeOf(crvs)): crv = irit.nth(crvs, i) irit.attrib(crv, "rgb", irit.GenStrObject(getrandrgb())) irit.snoc(crv * irit.sc(1), retval) i = i + 1 return retval
def plgntoplln( pl ): retval = irit.nil( ) j = 0 while ( j <= irit.SizeOf( pl ) - 1 ): irit.snoc( irit.coord( pl, j ), retval ) j = j + 1 irit.snoc( irit.coord( pl, 0 ), retval ) retval = irit.poly( retval, irit.TRUE ) irit.attrib( retval, "dwidth", irit.GenIntObject(3 )) return retval
def cubeat(x, y, z): retval = irit.box((x - size / 2.0, y - size / 2.0, z - size / 2.0), size, size, size) irit.attrib( retval, "rgb", irit.GenStrObject( str(int(irit.random(64, 255))) + "," + str(int(irit.random(64, 255))) + "," + str(int(irit.random(64, 255))))) return retval
def extractidparts(obj, id, rgb): retval = irit.nil() i = 0 while (i <= irit.SizeOf(obj) - 1): p = irit.coord(obj, i) if (irit.getattr(p, "id") == irit.GenRealObject(id)): irit.snoc(p, retval) i = i + 1 retval = irit.mergepoly(retval) irit.attrib(retval, "rgb", irit.GenStrObject(rgb)) return retval
def cornerunitshelf( w, h, legw, legd ): prof1 = ( irit.ctlpt( irit.E3, legd, legd, 0 ) + \ irit.ctlpt( irit.E3, legd, 2 * w - legd, 0 ) + \ irit.ctlpt( irit.E3, 2 * w - legd, 2 * w - legd, 0 ) ) prof2 = ( \ irit.ctlpt( irit.E3, legd, legd, 0 ) + irit.arc( ( w - legd, legd, 0 ), ( w, w, 0 ), ( 2 * w - legd, w - legd, 0 ) ) + \ irit.ctlpt( irit.E3, 2 * w - legd, 2 * w - legd, 0 ) ) shelfframe = irit.list( irit.extrude( prof1 + (-prof2 ), ( 0, 0, 0.03 ), 0 ), irit.ruledsrf( prof1, prof2 ), irit.ruledsrf( prof1, prof2 ) * irit.tz( 0.03 ) ) irit.attrib( shelfframe, "ptexture", woodtext ) irit.attrib( shelfframe, "rgb", woodclr ) retval = irit.list( shelfframe ) * irit.tz( h ) return retval
def virttree3(pos, dir, size, blevel, level): retval = irit.nil() newpos = (pos + dir) if (level > 0): tr = treebranch(pos, newpos, size) if (level >= blevel): irit.color(tr, bcolor) irit.attrib(tr, "ptexture", irit.GenStrObject("trunk.rle")) irit.attrib(tr, "rgb", irit.GenStrObject(brgb)) else: irit.color(tr, lcolor) irit.attrib(tr, "rgb", irit.GenStrObject(lrgb)) irit.attrib(tr, "ptexture", irit.GenStrObject("leaves.rle")) irit.snoc(tr, retval) if (level > 1): tr1 = virttree3(newpos, rotatevector2(dir, rfactor) * lfactor, size * wfactor, blevel, level - 1) tr2 = virttree3( newpos, rotatevector2(dir, rfactor * irit.random((-1), 1)) * lfactor, size * wfactor, blevel, level - 1) tr3 = virttree3(newpos, rotatevector2(dir, (-rfactor)) * lfactor, size * wfactor, blevel, level - 1) retval = retval + tr1 + tr2 + tr3 return retval
def cnvrtcrvs2ranges( crvs, idx, merge ): retval = irit.nil( ) if ( merge ): crvs = mergeverticalbndrycrvs( crvs ) i = 1 while ( i <= irit.SizeOf( crvs ) ): dm = irit.nth( crvs, i ) pt1 = irit.ceval( dm, 0 ) pt2 = irit.ceval( dm, 1 ) rng = irit.list( irit.coord( pt1, 2 ) ) + irit.list( irit.coord( pt2, 2 ) ) irit.attrib( rng, "index", irit.GenRealObject(idx) ) irit.snoc( rng, retval ) i = i + 1 return retval
def pawn(s, clr): retval = (-irit.surfprev( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0.0001, 0.635 ), \ irit.ctlpt( irit.E2, 0.06, 0.63 ), \ irit.ctlpt( irit.E2, 0.08, 0.56 ), \ irit.ctlpt( irit.E2, 0.06, 0.52 ), \ irit.ctlpt( irit.E2, 0.03, 0.5 ), \ irit.ctlpt( irit.E2, 0.03, 0.49 ), \ irit.ctlpt( irit.E2, 0.1, 0.48 ), \ irit.ctlpt( irit.E2, 0.1, 0.46 ), \ irit.ctlpt( irit.E2, 0.04, 0.44 ), \ irit.ctlpt( irit.E2, 0.05, 0.25 ), \ irit.ctlpt( irit.E2, 0.15, 0.1 ), \ irit.ctlpt( irit.E2, 0.15, 0 ) ), irit.list( irit.KV_OPEN ) ) * irit.rx( 90 ) ) ) * irit.sc( s ) irit.attrib(retval, "rgb", irit.GenStrObject(clr)) return retval
def computeorthovector(theta1, theta2, phi1, phi2): theta1d = theta1 * math.pi / 180 theta2d = theta2 * math.pi / 180 phi1d = phi1 * math.pi / 180 phi2d = phi2 * math.pi / 180 pt1 = irit.point( math.cos(theta1d) * math.cos(phi1d), math.cos(theta1d) * math.sin(phi1d), math.sin(theta1d)) pt2 = irit.point( math.cos(theta2d) * math.cos(phi2d), math.cos(theta2d) * math.sin(phi2d), math.sin(theta2d)) retval = irit.coerce(irit.normalizePt(pt1 ^ pt2), irit.VECTOR_TYPE) irit.attrib(retval, "dwidth", irit.GenRealObject(3)) irit.color(retval, irit.GREEN) return retval
def centerunitdoors( w, d, h, legw, legd ): intwidth = w/3 leftdoor = irit.box( ( legw + 0.002, 0, 0.202 ), intwidth - legw + 0.0096, 0.01, h - 0.204 - legw ) rot_z1 = ( irit.ctlpt( irit.E1, 0 ) + \ irit.ctlpt( irit.E1, 100 ) ) irit.attrib( leftdoor, "animation", irit.list( irit.tx( (-legw ) ), rot_z1, irit.tx( legw ) ) ) rightdoor = irit.box( ( intwidth * 2 + 0.002, 0, 0.202 ), intwidth - legw - 0.004, 0.01, h - 0.204 - legw ) rot_z2 = ( \ irit.ctlpt( irit.E1, 0 ) + \ irit.ctlpt( irit.E1, (-100 ) ) ) irit.attrib( rightdoor, "animation", irit.list( irit.tx( (-w ) + legw ), rot_z2, irit.tx( w - legw ) ) ) retval = irit.list( leftdoor, rightdoor ) irit.attrprop( retval, "ptexture", woodtext ) irit.attrprop( retval, "rgb", woodclr ) return retval
def computesphericalcrv(theta1, theta2, phi1, phi2): ptlist = irit.nil() t = 0 while (t <= 100): theta = (theta2 * t + theta1 * (100 - t)) * math.pi / (180 * 100) phi = (phi2 * t + phi1 * (100 - t)) * math.pi / (180 * 100) irit.snoc( irit.point( math.cos(theta) * math.cos(phi), math.cos(theta) * math.sin(phi), math.sin(theta)), ptlist) t = t + 1 retval = irit.cbspline(2, ptlist, irit.list(irit.KV_OPEN)) irit.attrib(retval, "dwidth", irit.GenRealObject(3)) irit.color(retval, irit.RED) return retval
def antantenna(): c = irit.pcircle((0, 0, 0), 0.03) * irit.ry(90) retval = (-irit.sfromcrvs( irit.list( c * irit.sy(1.4) * irit.rz(45) * irit.tx(0.1) * irit.ty((-0.15)), c * irit.rz(45) * irit.tx(0.2) * irit.ty(0.2), c * irit.sy(1.4) * irit.tx(0.3) * irit.ty(0.4), c * irit.rz((-55)) * irit.tx(0.4) * irit.ty(0.15), c * irit.sc(0.8) * irit.rz((-45)) * irit.tx(0.5) * irit.ty((-0.1)), c * irit.sc(0.65) * irit.rz((-45)) * irit.tx(0.58) * irit.ty( (-0.22)), c * irit.sc(0.001) * irit.rz((-45)) * irit.tx(0.58) * irit.ty( (-0.22))), 3, irit.KV_OPEN)) irit.attrib(retval, "rgb", irit.GenStrObject("255,50,50")) return retval
def queen(s, clr): queenbase = (-irit.surfprev( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0.001, 1.01 ), \ irit.ctlpt( irit.E2, 0.02, 1.01 ), \ irit.ctlpt( irit.E2, 0.02, 0.972 ), \ irit.ctlpt( irit.E2, 0.01, 0.972 ), \ irit.ctlpt( irit.E2, 0.01, 0.97 ), \ irit.ctlpt( irit.E2, 0.09, 0.96 ), \ irit.ctlpt( irit.E2, 0.1, 0.912 ), \ irit.ctlpt( irit.E2, 0.1, 0.911 ), \ irit.ctlpt( irit.E2, 0.12, 0.911 ), \ irit.ctlpt( irit.E2, 0.12, 0.91 ), \ irit.ctlpt( irit.E2, 0.09, 0.84 ), \ irit.ctlpt( irit.E2, 0.07, 0.76 ), \ irit.ctlpt( irit.E2, 0.07, 0.74 ), \ irit.ctlpt( irit.E2, 0.085, 0.74 ), \ irit.ctlpt( irit.E2, 0.085, 0.72 ), \ irit.ctlpt( irit.E2, 0.07, 0.72 ), \ irit.ctlpt( irit.E2, 0.07, 0.7 ), \ irit.ctlpt( irit.E2, 0.1, 0.68 ), \ irit.ctlpt( irit.E2, 0.1, 0.66 ), \ irit.ctlpt( irit.E2, 0.14, 0.64 ), \ irit.ctlpt( irit.E2, 0.14, 0.62 ), \ irit.ctlpt( irit.E2, 0.06, 0.57 ), \ irit.ctlpt( irit.E2, 0.09, 0.33 ), \ irit.ctlpt( irit.E2, 0.21, 0.14 ), \ irit.ctlpt( irit.E2, 0.21, 0 ) ), irit.list( irit.KV_OPEN ) ) * irit.rx( 90 ) ) ) queencrwn = (-irit.swpsclsrf( \ irit.ctlpt( irit.E2, (-0.1 ), 0 ) + \ irit.ctlpt( irit.E2, 0.1, 0 ) + \ irit.ctlpt( irit.E2, (-0.42 ), (-0.7 ) ) + \ irit.ctlpt( irit.E2, (-0.44 ), (-0.7 ) ) + \ irit.ctlpt( irit.E2, (-0.1 ), 0 ), irit.pcircle( ( 0, 0, 0 ), 1 ), irit.creparam( irit.coerce( irit.cbspline( 3, irit.list( \ irit.ctlpt( irit.E2, 0, (-0.3 ) ), \ irit.ctlpt( irit.E2, 1, 1.5 ), \ irit.ctlpt( irit.E2, 2, (-0.3 ) ), \ irit.ctlpt( irit.E2, 3, 1.5 ), \ irit.ctlpt( irit.E2, 4, (-0.3 ) ), \ irit.ctlpt( irit.E2, 5, 1.5 ), \ irit.ctlpt( irit.E2, 6, (-0.3 ) ), \ irit.ctlpt( irit.E2, 7, 1.5 ), \ irit.ctlpt( irit.E2, 8, (-0.3 ) ), \ irit.ctlpt( irit.E2, 9, 1.5 ), \ irit.ctlpt( irit.E2, 10, (-0.3 ) ), \ irit.ctlpt( irit.E2, 11, 1.5 ) ), irit.list( irit.KV_PERIODIC ) ), irit.KV_OPEN ), 0, 1 ), irit.point( 0, 0, (-1 ) ), 2 ) ) * irit.sc( 0.11 ) * irit.tz( 0.911 ) irit.attrib(queencrwn, "rgb", irit.GenStrObject("255,255,100")) irit.attrib(queenbase, "rgb", irit.GenStrObject(clr)) retval = irit.list(queenbase, queencrwn) * irit.sc(s) return retval
def randomcrvs(numcrvs, crvdeg, crvlen, size, dwidth): l = irit.nil() i = 1 while (i <= numcrvs): irit.snoc(genrandomcrv(crvdeg, crvlen, size), l) irit.attrib(irit.nref(l, i), "gray", irit.GenRealObject(irit.random(0.01, 0.7))) i = i + 1 i = 1 while (i <= numcrvs): irit.attrib(irit.nref(l, i), "rgb", irit.GenStrObject(getrandrgb())) i = i + 1 retval = l irit.color(retval, irit.RED) irit.awidth(retval, 0.01) irit.adwidth(retval, dwidth) return retval
def antrleganim(s): retval = antleg() * irit.ry(180) t = 0.2 * (s + 1) / 2 rot_y = irit.creparam( irit.cbspline( 2, irit.list( irit.ctlpt( irit.E1, 13 * s ), \ irit.ctlpt( irit.E1, (-13 ) * s ), \ irit.ctlpt( irit.E1, (-13 ) * s ), \ irit.ctlpt( irit.E1, 13 * s ) ), irit.list( 0, 0, 1.3, 1.7, 3, 3 ) ),\ 0 + t, 1 + t ) rot_z = irit.creparam( irit.cbspline( 2, irit.list( \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 7 + 7 * s ), \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 7 - 7 * s ), \ irit.ctlpt( irit.E1, 0 ) ), irit.list( irit.KV_OPEN ) ), 0 + t, 1 + t ) irit.attrib(retval, "animation", irit.list(rot_z, rot_y)) return retval
def warpsurface( srf, tv ): usize = irit.FetchRealObject(irit.nth( irit.ffmsize( srf ), 1 )) vsize = irit.FetchRealObject(irit.nth( irit.ffmsize( srf ), 2 )) clr = irit.getattr( srf, "color" ) i = 0 while ( i <= usize * vsize - 1 ): pt = irit.coord( srf, i ) x = irit.FetchRealObject(irit.coord( pt, 1 )) y = irit.FetchRealObject(irit.coord( pt, 2 )) z = irit.FetchRealObject(irit.coord( pt, 3 )) pt = irit.teval( tv, x, y, z ) v = math.floor( i/float(usize) ) u = i - v * usize srf = irit.seditpt( srf, pt, u, v ) i = i + 1 irit.attrib( srf, "color", clr ) retval = srf return retval
def genanimationorthomatchcrvpts(ppl, crv, scl): pt1 = irit.point(0, 0, 0) pt2 = irit.point(0, 0, 0) vec1 = ( irit.ctlpt( irit.E2, 0, 0 ) + \ irit.ctlpt( irit.E2, 0, scl ) ) irit.color(vec1, irit.YELLOW) vec2 = ( \ irit.ctlpt( irit.E2, 0, 0 ) + \ irit.ctlpt( irit.E2, 0, scl ) ) irit.color(vec2, irit.CYAN) pos1 = irit.nil() pos2 = irit.nil() rot1 = irit.nil() rot2 = irit.nil() i = 0 while (i <= irit.SizeOf(ppl) - 1): pl = irit.coord(ppl, i) j = 0 while (j <= irit.SizeOf(pl) - 1): pt = irit.coord(pl, j) t1 = irit.coord(pt, 0) t2 = irit.coord(pt, 1) if (t1 > t2): irit.snoc( irit.coerce(irit.ceval(crv, irit.FetchRealObject(t1)), irit.POINT_TYPE), pos1) irit.snoc( irit.coerce(irit.ceval(crv, irit.FetchRealObject(t2)), irit.POINT_TYPE), pos2) n1 = irit.cnormal(crv, irit.FetchRealObject(t1)) n2 = irit.cnormal(crv, irit.FetchRealObject(t2)) irit.snoc( irit.vector( math.atan2(irit.FetchRealObject(irit.coord(n1, 0)), irit.FetchRealObject(irit.coord(n1, 1))) * 180 / math.pi, 0, 0), rot1) irit.snoc( irit.vector( math.atan2(irit.FetchRealObject(irit.coord(n2, 0)), irit.FetchRealObject(irit.coord(n2, 1))) * 180 / math.pi, 0, 0), rot2) j = j + 1 if (t1 > t2): irit.snoc(irit.vector(10000, 0, 0), pos1) irit.snoc(irit.vector(10000, 0, 0), pos2) irit.snoc(irit.vector(0, 0, 0), rot1) irit.snoc(irit.vector(0, 0, 0), rot2) i = i + 1 irit.attrib(pt1, "animation", makerottransanimobj(irit.nil(), pos1)) irit.attrib(pt2, "animation", makerottransanimobj(irit.nil(), pos2)) irit.attrib(vec1, "animation", makerottransanimobj(rot1, pos1)) irit.attrib(vec2, "animation", makerottransanimobj(rot2, pos2)) retval = irit.list(pt1, pt2, vec1, vec2) return retval
def king(s, clr): kingbase = (-irit.surfprev( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0.001, 1.04 ), \ irit.ctlpt( irit.E2, 0.04, 1.04 ), \ irit.ctlpt( irit.E2, 0.04, 1.02 ), \ irit.ctlpt( irit.E2, 0.06, 1.02 ), \ irit.ctlpt( irit.E2, 0.06, 1 ), \ irit.ctlpt( irit.E2, 0.08, 1 ), \ irit.ctlpt( irit.E2, 0.08, 0.97 ), \ irit.ctlpt( irit.E2, 0.1, 0.97 ), \ irit.ctlpt( irit.E2, 0.1, 0.94 ), \ irit.ctlpt( irit.E2, 0.07, 0.82 ), \ irit.ctlpt( irit.E2, 0.07, 0.8 ), \ irit.ctlpt( irit.E2, 0.09, 0.8 ), \ irit.ctlpt( irit.E2, 0.09, 0.78 ), \ irit.ctlpt( irit.E2, 0.07, 0.78 ), \ irit.ctlpt( irit.E2, 0.07, 0.74 ), \ irit.ctlpt( irit.E2, 0.1, 0.72 ), \ irit.ctlpt( irit.E2, 0.1, 0.7 ), \ irit.ctlpt( irit.E2, 0.14, 0.67 ), \ irit.ctlpt( irit.E2, 0.14, 0.64 ), \ irit.ctlpt( irit.E2, 0.06, 0.57 ), \ irit.ctlpt( irit.E2, 0.09, 0.33 ), \ irit.ctlpt( irit.E2, 0.21, 0.14 ), \ irit.ctlpt( irit.E2, 0.21, 0 ) ), irit.list( irit.KV_OPEN ) ) * irit.rx( 90 ) ) ) kingcrosscrv = ( \ irit.ctlpt( irit.E2, (-0.07 ), 0 ) + \ irit.ctlpt( irit.E2, (-0.07 ), 0.53 ) + \ irit.ctlpt( irit.E2, (-0.3 ), 0.53 ) + \ irit.ctlpt( irit.E2, (-0.3 ), 0.67 ) + \ irit.ctlpt( irit.E2, (-0.07 ), 0.67 ) + \ irit.ctlpt( irit.E2, (-0.07 ), 1 ) + \ irit.ctlpt( irit.E2, 0, 1 ) ) kingcrosssrf1 = irit.ruledsrf(kingcrosscrv, kingcrosscrv * irit.sx((-1))) kingcrosssrf2 = (-kingcrosssrf1) * irit.tz(0.08) kingcrosscrv2 = (kingcrosscrv + (-kingcrosscrv) * irit.sx((-1))) kingcrosssrf3 = irit.ruledsrf(kingcrosscrv2, kingcrosscrv2 * irit.tz(0.08)) kingcross = irit.list( kingcrosssrf1, kingcrosssrf2, kingcrosssrf3) * irit.tz( (-0.04)) * irit.sc(0.16) * irit.rx(90) * irit.tz(1) irit.attrib(kingcross, "rgb", irit.GenStrObject("255,255,100")) irit.attrib(kingbase, "rgb", irit.GenStrObject(clr)) retval = irit.list(kingbase, kingcross) * irit.sc(s) return retval
def mergeverticalbndrycrvs( crvs ): crvs = crvs * irit.tx( 0 ) retval = irit.nil( ) i = 1 while ( i <= irit.SizeOf( crvs ) ): c1 = irit.nth( crvs, i ) used = irit.getattr( c1, "used" ) if ( irit.ThisObject( used ) != irit.NUMERIC_TYPE ): j = i + 1 while ( j <= irit.SizeOf( crvs ) ): c2 = irit.nth( crvs, j ) used = irit.getattr( c2, "used" ) if ( irit.ThisObject( used ) != irit.NUMERIC_TYPE ): c1a = mergeverticaltwocrvs( c1, c2 ) if ( c1a != c1 ): irit.attrib( irit.nref( crvs, j ), "used", irit.GenIntObject(1 )) c1 = c1a j = j + 1 irit.snoc( c1 * irit.tx( 0 ), retval ) i = i + 1 return retval
def evalonebitangency(srfs, pts): ruling = irit.nil() tmp1pts = irit.nil() tmp2pts = irit.nil() if (irit.ThisObject(srfs) == irit.SURFACE_TYPE): srf1 = srfs srf2 = srfs else: srf1 = irit.nth(srfs, 1) srf2 = irit.nth(srfs, 2) i = 1 while (i <= irit.SizeOf(pts)): pt = irit.nth(pts, i) pt1 = irit.seval(srf1, irit.FetchRealObject(irit.coord(pt, 1)), irit.FetchRealObject(irit.coord(pt, 2))) pt2 = irit.seval(srf2, irit.FetchRealObject(irit.coord(pt, 3)), irit.FetchRealObject(irit.coord(pt, 4))) irit.snoc(pt1 + pt2, ruling) irit.snoc(pt1 * irit.tx(0), tmp1pts) irit.snoc(pt2 * irit.tx(0), tmp2pts) i = i + 1 irit.attrib(ruling, "rgb", irit.GenStrObject("255, 128, 128")) if (irit.SizeOf(tmp1pts) > 1 and irit.SizeOf(tmp2pts) > 1): tmp1pts = irit.poly(tmp1pts, irit.TRUE) tmp2pts = irit.poly(tmp2pts, irit.TRUE) irit.attrib(tmp1pts, "rgb", irit.GenStrObject("128, 255, 128")) irit.attrib(tmp2pts, "rgb", irit.GenStrObject("128, 255, 128")) retval = irit.list(ruling, tmp1pts, tmp2pts) else: retval = irit.nil() return retval
def computeviews( c, step, fname ): dms = buildvisibilitymap( c, step ) ranges = irit.nil( ) i = 1 while ( i <= irit.SizeOf( dms ) ): ranges = cnvrtcrvs2ranges( irit.nth( dms, i ), i, 1 ) + ranges i = i + 1 irit.printf( "%d views are considered\n", irit.list( irit.SizeOf( dms ) ) ) cvrs = irit.setcover( ranges, 0.001 ) cvrcrvs = irit.nil( ) i = 1 while ( i <= irit.SizeOf( cvrs ) ): cvr = irit.nth( ranges, irit.FetchRealObject(irit.nth( cvrs, i )) + 1 ) irit.printf( "curve %d [idx = %d] covers from t = %f to t = %f\n", irit.list( i, irit.getattr( cvr, "index" ), irit.nth( cvr, 1 ), irit.nth( cvr, 2 ) ) ) irit.snoc( extractcrvregion( c, irit.nth( cvr, 1 ), irit.nth( cvr, 2 ), (irit.getattr( cvr, "index" )/irit.SizeOf( dms ) ) * 360 ), cvrcrvs ) i = i + 1 irit.attrib( c, "width", irit.GenRealObject(0.005 )) irit.attrib( c, "rgb", irit.GenStrObject("255, 255, 255" )) retval = irit.list( c, cvrcrvs ) if ( irit.SizeOf( irit.GenStrObject( fname ) ) > 0 ): irit.save( fname, retval ) return retval
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
def displayobjobjhdres( o1, o2, eps, onesided ): global glbltransx hdres = irit.hausdorff( o1, o2, eps, onesided ) dist = irit.nth( hdres, 1 ) param1 = irit.nth( hdres, 2 ) if ( onesided ): dtype = "one sided " else: dtype = "two sided " if ( irit.SizeOf( param1 ) == 0 ): pt1 = irit.coerce( o1, irit.E3 ) else: i = 1 while ( i <= irit.SizeOf( param1 ) ): t = irit.nth( param1, i ) irit.printf( "%shausdorff distance %f detected at t1 = %f\n", irit.list( dtype, dist, t ) ) i = i + 1 pt1 = irit.ceval( o1, irit.FetchRealObject(t) ) param2 = irit.nth( hdres, 3 ) if ( irit.SizeOf( param2 ) == 0 ): pt2 = irit.coerce( o2, irit.E3 ) else: i = 1 while ( i <= irit.SizeOf( param2 ) ): t = irit.FetchRealObject(irit.nth( param2, i )) irit.printf( "%shausdorff distance %f detected at t2 = %f\n", irit.list( dtype, dist, t ) ) i = i + 1 pt2 = irit.ceval( o2, t ) irit.color( pt1, irit.MAGENTA ) irit.color( o1, irit.MAGENTA ) irit.color( pt2, irit.YELLOW ) irit.color( o2, irit.YELLOW ) l = ( pt1 + pt2 ) if ( onesided == 0 ): irit.attrib( l, "dwidth", irit.GenIntObject(3 )) all = irit.list( o1, o2, pt1, pt2, l ) irit.snoc( all * irit.tx( glbltransx ), glblres ) glbltransx = ( glbltransx + 0.5 ) irit.interact( all )