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 evaltv(tv, ulen, vlen, wlen): retval = irit.nil() dom = irit.pdomain(tv) i = 0 while (i <= ulen - 1): u = irit.FetchRealObject(irit.nth(dom, 1)) + i * irit.FetchRealObject( irit.nth(dom, 2) - irit.nth(dom, 1)) / float(ulen - 1) lst2 = irit.nil() j = 0 while (j <= vlen - 1): v = irit.FetchRealObject(irit.nth( dom, 3)) + j * irit.FetchRealObject( irit.nth(dom, 4) - irit.nth(dom, 3)) / float(vlen - 1) lst3 = irit.nil() k = 0 while (k <= wlen - 1): w = irit.FetchRealObject(irit.nth( dom, 5)) + k * irit.FetchRealObject( irit.nth(dom, 6) - irit.nth(dom, 5)) / float(wlen - 1) irit.snoc(irit.teval(tv, u, v, w), lst3) k = k + 1 irit.snoc(lst3 * irit.tx(0), lst2) j = j + 1 irit.snoc(lst2 * irit.tx(0), retval) i = i + 1 retval = irit.tbezier(retval) 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 squareunitlegs( w, d, h, legw, legd ): grooved = ( legw - legd ) lleg = ( irit.box( ( 0, 0, 0 ), legw, legd, h ) - irit.box( ( legw/3, (-0.01 ), 0.1 ), legw/3, 0.02, h - 0.3 ) - irit.box( ( (-0.01 ), legd/3, 0.1 ), 0.02, legd/3, h - 0.3 ) - irit.box( ( legw - grooved, legd - 0.02, 0.2 ), 0.1, 0.1, h - 0.3 ) ) rleg = ( irit.box( ( 0, 0, 0 ), legw, legd, h ) - irit.box( ( legw/3, (-0.01 ), 0.1 ), legw/3, 0.02, h - 0.3 ) - irit.box( ( legw - 0.01, legd/3, 0.1 ), 0.02, legd/3, h - 0.3 ) - irit.box( ( grooved, legd - 0.02, 0.2 ), (-0.1 ), 0.1, h - 0.3 ) ) retval = irit.list( lleg, rleg * irit.tx( w - legw ), lleg * irit.rz( 180 ) * irit.tx( w ) * irit.ty( d ), rleg * irit.rz( 180 ) * irit.tx( legw ) * irit.ty( d ) ) irit.attrprop( retval, "ptexture", woodtext ) irit.attrprop( retval, "rgb", woodclr ) return retval
def cornerunitlegs( w, h, legw, legd ): grooved = ( legw - legd ) lleg = ( irit.box( ( 0, 0, 0 ), legw, legd, h ) - irit.box( ( legw/3, (-0.01 ), 0.1 ), legw/3, 0.02, h - 0.3 ) - irit.box( ( (-0.01 ), legd/3, 0.1 ), 0.02, legd/3, h - 0.3 ) - irit.box( ( legd, legd - 0.02, 0.2 ), 0.1, 0.1, h - 0.3 ) ) sleg = ( irit.box( ( 0, 0, 0 ), legw, legd, h ) - irit.box( ( legw/3, (-0.01 ), 0.1 ), legw/3, 0.02, h - 0.3 ) - irit.box( ( (-0.1 ), legd - 0.02, 0.2 ), 0.2, 0.1, h - 0.3 ) ) rleg = ( irit.box( ( 0, 0, 0 ), legw, legd, h ) - irit.box( ( legw/3, (-0.01 ), 0.1 ), legw/3, 0.02, h - 0.3 ) - irit.box( ( legw - 0.01, legd/3, 0.1 ), 0.02, legd/3, h - 0.3 ) - irit.box( ( grooved, legd - 0.02, 0.2 ), (-0.1 ), 0.1, h - 0.3 ) ) cleg = ( irit.box( ( 0, 0, 0 ), legw, legw, h ) - irit.box( ( legd, legd, 0.2 ), 0.1, 0.1, h - 0.3 ) ) retval = irit.list( lleg, sleg * irit.tx( w - legw ), sleg * irit.tx( w ) * irit.rz( 90 ) * irit.tx( 2 * w ), rleg * irit.rz( 90 ) * irit.tx( 2 * w ) * irit.ty( 2 * w - legw ), cleg * irit.rz( (-90 ) ) * irit.ty( w * 2 ) ) irit.attrprop( retval, "ptexture", woodtext ) irit.attrprop( retval, "rgb", woodclr ) return retval
def cornerunitbars( w, h, legw, legd ): sbar = irit.box( ( legw, 0, 0 ), w - 2 * legw, legd, legw ) lbar = irit.box( ( legd, 0, 0 ), 2 * w - legd - legw, legd, legw ) arcbar1 = irit.arc( ( w, 0, 0 ), ( w, w, 0 ), ( 2 * w, w, 0 ) ) arcbar2 = irit.offset( arcbar1, (-legd ), 0.1, 0 ) arcbar = irit.list( irit.extrude( arcbar1 + (-arcbar2 ) + irit.ctlpt( irit.E3, w, 0, 0 ), ( 0, 0, legw ), 0 ), irit.ruledsrf( arcbar1, arcbar2 ), irit.ruledsrf( arcbar1, arcbar2 ) * irit.tz( legw ) ) barframe = irit.list( arcbar, sbar, sbar * irit.tx( w ) * irit.rz( 90 ) * irit.tx( 2 * w ), lbar * irit.rz( 90 ) * irit.tx( legd ), lbar * irit.tx( legw - legd ) * irit.ty( 2 * w - legd ) ) retval = irit.list( barframe * irit.tz( 0.1 ), barframe * irit.tz( h - 0.1 ) ) irit.attrprop( retval, "ptexture", woodtext ) irit.attrprop( retval, "rgb", woodclr ) return retval
def do_coplanars(a, b, fname): irit.interact(irit.list(a, b)) c1 = (a + b) irit.interact(c1) c2 = a * b irit.interact(c2) c3 = (a - b) irit.interact(c3) c4 = (b - a) irit.interact(c4) irit.save( fname, irit.list(c1, c2 * irit.tx(4), c3 * irit.tx(8), c4 * irit.tx(12)))
def computetopoaspectgraph(s, spc): ag = irit.saspctgrph(s) irit.color(ag, irit.YELLOW) irit.adwidth(ag, 3) sp = irit.spheresrf(1) irit.color(sp, irit.RED) s1 = s * irit.tx(0) irit.color(s1, irit.GREEN) irit.adwidth(s1, 2) retval = irit.list( irit.list(ag, sp, irit.GetAxes()) * irit.sc(0.6) * irit.tx(spc), irit.list(s1, irit.GetAxes()) * irit.tx((-spc))) 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 displayobjobjmdres(o1, o2, eps): global glbltransx mdres = irit.mindist2ff(o1, o2, eps) dist = irit.nth(mdres, 1) param1 = irit.nth(mdres, 2) param2 = irit.nth(mdres, 3) if (irit.SizeOf(param1) == 0): pt1 = irit.coerce(o1, irit.E3) else: prm = irit.nth(param1, 1) if (irit.ThisObject(prm) == irit.NUMERIC_TYPE): i = 1 while (i <= irit.SizeOf(param1)): t = irit.nth(param1, i) irit.printf("min distance %f detected at t1 = %f\n", irit.list(dist, t)) i = i + 1 pt1 = irit.ceval(o1, irit.FetchRealObject(t)) else: i = 1 while (i <= irit.SizeOf(param1)): uv = irit.nth(param1, i) irit.printf("min distance %f detected at uv1 = %f %f\n", irit.list(dist, irit.nth(uv, 1), irit.nth(uv, 2))) i = i + 1 pt1 = irit.seval( o1, irit.FetchRealObject(irit.nth(irit.nth(param1, 1), 1)), irit.FetchRealObject(irit.nth(irit.nth(param1, 1), 2))) if (irit.SizeOf(param2) == 0): pt2 = irit.coerce(o2, irit.E3) else: prm = irit.nth(param2, 1) if (irit.ThisObject(prm) == irit.NUMERIC_TYPE): i = 1 while (i <= irit.SizeOf(param2)): t = irit.nth(param2, i) irit.printf("min distance %f detected at t2 = %f\n", irit.list(dist, t)) i = i + 1 pt2 = irit.ceval(o2, irit.FetchRealObject(t)) else: i = 1 while (i <= irit.SizeOf(param2)): uv = irit.nth(param2, i) irit.printf("min distance %f detected at uv2 = %f %f\n", irit.list(dist, irit.nth(uv, 1), irit.nth(uv, 2))) i = i + 1 pt2 = irit.seval( o2, irit.FetchRealObject(irit.nth(irit.nth(param2, 1), 1)), irit.FetchRealObject(irit.nth(irit.nth(param2, 1), 2))) irit.color(pt1, irit.MAGENTA) irit.color(o1, irit.MAGENTA) irit.color(pt2, irit.YELLOW) irit.color(o2, irit.YELLOW) l = (pt1 + pt2) all = irit.list(o1, o2, pt1, pt2, l) irit.snoc(all * irit.tx(glbltransx), glblres) glbltransx = (glbltransx + 0.5) irit.interact(all)
def squareunitbars( w, d, h, legw, legd ): fbar = irit.box( ( legw, 0, 0 ), w - 2 * legw, legd, legw ) sbar = irit.box( ( 0, legd, 0 ), legd, d - 2 * legd, legw ) barframe = irit.list( fbar, sbar, fbar * irit.ty( d - legd ), sbar * irit.tx( w - legd ) ) retval = irit.list( barframe * irit.tz( 0.1 ), barframe * irit.tz( h - 0.1 ) ) irit.attrprop( retval, "ptexture", woodtext ) irit.attrprop( retval, "rgb", woodclr ) return retval
def snakepiece(clr, xrot, ypos, zpos): retval = (irit.box((0, 0, (-0.1)), 1, 1.1, 1.1) - irit.box( (0, (-1), (-2)), 2, 3, 2) * irit.rx(45) * irit.tx((-0.5))) retval = retval * irit.sc(1.0 / math.sqrt(2)) * irit.rx( (-225)) * irit.trans(((-1) / (2.0 * math.sqrt(2)), 1, 0.5)) retval = retval * irit.rx(xrot) * irit.ty(ypos) * irit.tz(zpos) irit.color(retval, clr) return retval
def sideunitwalls( w, d, h, legw, legd ): backwall = irit.box( ( legd, d - legd - 0.018, 0.2 ), w - 2 * legd, 0.002, h - 0.3 ) irit.attrib( backwall, "ptexture", woodtext ) irit.attrib( backwall, "rgb", woodclr ) leftwall = irit.box( ( legd + 0.001, legd, 0.2 ), 0.002, d - 2 * legd, h - 0.3 ) rightwall = irit.box( ( w - legd - 0.003, legd, 0.2 ), 0.002, d - 2 * legd, h - 0.3 ) irit.attrib( leftwall, "transp", irit.GenRealObject(0.3 )) irit.attrib( rightwall, "transp", irit.GenRealObject(0.3 )) frontdoorframe = ( irit.box( ( legw + 0.001, 0, 0.201 ), w - 2 * legw - 0.002, 0.015, h - 0.302 ) - irit.box( ( legw + 0.03, (-0.1 ), 0.23 ), w - 2 * legw - 0.062, 0.5, h - 0.362 ) - irit.box( ( legw + 0.02, 0.01, 0.22 ), w - 2 * legw - 0.04, 0.1, h - 0.34 ) ) irit.attrib( frontdoorframe, "ptexture", woodtext ) irit.attrib( frontdoorframe, "rgb", woodclr ) frontdoorglass = irit.box( ( legw + 0.021, 0.011, 0.221 ), w - 2 * legw - 0.042, 0.003, h - 0.342 ) irit.attrib( frontdoorglass, "transp", irit.GenRealObject(0.3) ) frontdoor = irit.list( frontdoorframe, frontdoorglass ) rot_z = ( irit.ctlpt( irit.E1, 0 ) + \ irit.ctlpt( irit.E1, 100 ) ) irit.attrib( frontdoor, "animation", irit.list( irit.tx( (-legw ) ), rot_z, irit.tx( legw ) ) ) retval = irit.list( backwall, leftwall, rightwall, frontdoor ) return retval
def mergeverticaltwocrvs( c1, c2 ): x = irit.coord( irit.coord( c1, 1 ), 1 ) if ( apxeq( irit.coord( irit.coord( c1, 1 ), 2 ), 1 ) * apxeq( irit.coord( irit.coord( c2, 0 ), 2 ), 0 ) ): retval = irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c1, 0 ), 2 ) - 1 ) + \ irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c2, 1 ), 2 ) ) else: if ( apxeq( irit.coord( irit.coord( c2, 1 ), 2 ), 1 ) * apxeq( irit.coord( irit.coord( c1, 0 ), 2 ), 0 ) ): retval = \ irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c2, 0 ), 2 ) - 1 ) + \ irit.ctlpt( irit.E2, x, irit.coord( irit.coord( c1, 1 ), 2 ) ) else: retval = c1 * irit.tx( 0 ) return retval
def makealpha( a, clr ): aa = ( 2 * a - 1 )/float(a * a) alp = irit.quadric( irit.list( aa, 1, 1, 0, 0, 0,\ (-2 ), 0, 0, 1 ) ) if ( a < 0.5 ): alp1 = irit.sregion( irit.sregion( alp, irit.ROW, 0, 1 ), irit.COL, 0,\ 0.7 ) alp1 = irit.smoebius( irit.smoebius( alp1, 0, irit.COL ), 0, irit.ROW ) else: alp1 = alp * irit.tx( 0 ) retval = irit.list( alp1, alp1 * irit.rx( 90 ), alp1 * irit.rx( 180 ), alp1 * irit.rx( 270 ) ) irit.color( retval, clr ) irit.adwidth( retval, 3 ) return retval
def cornerunitwalls( w, h, legw, legd ): lwall = irit.box( ( legd, 0, 0.2 ), 2 * w - 2 * legd, 0.002, h - 0.3 ) irit.attrib( lwall, "ptexture", woodtext ) irit.attrib( lwall, "rgb", woodclr ) swall = irit.box( ( legd, 0, 0.2 ), w - 2 * legd, 0.002, h - 0.3 ) irit.attrib( swall, "transp", irit.GenRealObject(0.3 )) arcbar1 = irit.arc( ( w, 0, 0 ), ( w, w, 0 ), ( 2 * w, w, 0 ) ) arcbar2 = irit.offset( arcbar1, irit.GenRealObject(-0.03 ), 0.1, 0 ) arcbar = irit.list( irit.extrude( arcbar1 + (-arcbar2 ) + irit.ctlpt( irit.E3, w, 0, 0 ), ( 0, 0, 0.03 ), 0 ), irit.ruledsrf( arcbar1, arcbar2 ), irit.ruledsrf( arcbar1, arcbar2 ) * irit.tz( 0.03 ) ) rdoorframe = irit.list( irit.box( ( w, 0, 0.2 ), 0.03, 0.03, h - 0.3 ),\ irit.box( ( 2 * w - 0.03, w - 0.03, 0.2 ), 0.03, 0.03, h - 0.3 ),\ arcbar * irit.tz( 0.2 ), arcbar * irit.tz( h - 0.1 - 0.03 ) ) irit.attrib( rdoorframe, "ptexture", woodtext ) irit.attrib( rdoorframe, "rgb", woodclr ) rdoorglass = irit.extrude( irit.offset( arcbar1, irit.GenRealObject(-0.02 ), 0.1, 0 ) + (-irit.offset( arcbar1, irit.GenRealObject(-0.03 ), 0.1, 0 ) ) + \ irit.ctlpt( irit.E3, w - 0.02, 0, 0 ), ( 0, 0, h - 0.3 - 0.04 ), 0 ) * irit.tz( 0.22 ) irit.attrib( rdoorglass, "transp", irit.GenRealObject(0.3 )) rdoor = irit.list( rdoorframe, rdoorglass ) rot_z = ( \ irit.ctlpt( irit.E1, 0 ) + \ irit.ctlpt( irit.E1, 130 ) ) irit.attrib( rdoor, "animation", irit.list( irit.tx( (-w ) ), rot_z, irit.tx( w ) ) ) retval = irit.list( lwall * irit.ty( 2 * w ), swall * irit.rz( 90 ) * irit.tx( 2 * w ) * irit.ty( w ), lwall * irit.rz( 90 ), swall, rdoor ) 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 )