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 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 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 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
retval = warpsrf(obj, tv) else: if (irit.ThisObject(obj) == irit.POLY_TYPE): retval = warppoly(obj, tv) else: retval = obj * irit.tx(0) return retval # # Define the FFD trivariate # teapot = teapotorig * \ irit.sc( 0.2 ) * \ irit.sx( (-1 ) ) * \ irit.rx( 90 ) * \ irit.rz( 180 ) s = irit.planesrf((-1), (-1), 1, 1) * irit.sc(2.4) discs = irit.list( s * \ irit.sc( 0.02 ) * \ irit.sx( 2 ) * \ irit.tx( 0.56 ) * \ irit.tz( 0.42 ), s * \ irit.sc( 0.02 ) * \ irit.sx( 2 ) * \ irit.trans( ( 0.66, 0, 0.5 ) ), s * \ irit.sc( 0.04 ) * \ irit.sx( 1.5 ) * \
"principal curvatures at (u, v) = (%f, %f) equal %.9f and %.9f\n", irit.list(irit.coord(umb, 0), irit.coord(umb, 1), irit.nth(crvtr, 1), irit.nth(crvtr, 3))) irit.snoc( irit.seval(srf, irit.FetchRealObject(irit.coord(umb, 0)), irit.FetchRealObject(irit.coord(umb, 1))), retval) i = i + 1 irit.color(retval, irit.YELLOW) return retval # ################################ s = irit.surfprev( irit.cregion(irit.pcircle((0, 0, 0), 1), 0.001, 1.999) * irit.rx(90)) * irit.sx(0.8) * irit.sy(1.2) irit.color(s, irit.RED) paramumb = irit.sumbilic(s, 0.2, 1e-006) irit.interact(irit.list(evaltoeuclidean(s, paramumb), s)) # ################################ c = irit.cbspline( 4, irit.list( irit.ctlpt( irit.E2, 0.215, 0.427 ), \ irit.ctlpt( irit.E2, 1.34, 0.317 ), \ irit.ctlpt( irit.E2, 1.25, (-0.791 ) ), \ irit.ctlpt( irit.E2, (-0.573 ), (-1.05 ) ), \ irit.ctlpt( irit.E2, 1.12, (-1.31 ) ), \ irit.ctlpt( irit.E2, 1.19, (-1.51 ) ) ), irit.list( irit.KV_OPEN ) ) s = irit.sregion(irit.surfprev(c * irit.rx(90)), irit.COL, 0, 1) irit.color(s, irit.RED)
# Gershon Elber, May 1998 # ri = irit.iritstate("randominit", irit.GenRealObject(1964)) # Seed-initiate the randomizer, irit.free(ri) size = 0.25 v1 = (0, 0, 0) v2 = (size * 3, 0, 0) v3 = (size * 3, size * 3, 0) v4 = (0, size * 3, 0) plaux = irit.poly(irit.list(v1, v2, v3, v4, v1), irit.TRUE) cubebbox = irit.list(plaux, plaux * irit.tz(size * 3), plaux * irit.rx(90), plaux * irit.rx(90) * irit.ty(size * 3), plaux * irit.ry((-90)), plaux * irit.ry((-90)) * irit.tx(size * 3)) irit.attrib(cubebbox, "rgb", irit.GenStrObject("255, 255, 255")) irit.free(plaux) 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))) + "," +
# ################################ bar1 = ( irit.box( ( (-3 ), (-0.5 ), 1 ), 6, 1, 2 ) - \ (irit.box( ( (-0.5 ), (-1 ), 1 ), 1, 1, 3 ) + \ irit.box( ( (-0.5 ), (-1 ), 2 ), 1, 3, 2 ) )) irit.attrib(bar1, "rgb", irit.GenStrObject("0, 255, 0")) bar2 = (irit.box(((-0.5), 1, (-3)), 1, 2, 6) - irit.box( ((-1), 2, (-0.5)), 2, 2, 1)) irit.attrib(bar2, "rgb", irit.GenStrObject("100, 255, 0")) bar3 = bar2 * irit.rz(180) irit.attrib(bar2, "rgb", irit.GenStrObject("20, 255, 100")) bar4 = bar1 * irit.rx(180) irit.attrib(bar4, "rgb", irit.GenStrObject("100, 255, 100")) # ################################ block1 = (irit.box(((-3), (-3), (-3)), 2.5, 6, 6) - irit.box( ((-1), (-4), (-0.5)), 1, 8, 1) + irit.box( ((-5), (-0.5), (-4)), 6, 1, 8) + irit.box(((-1.001), (-1), (-0.5)), (-0.5), 2, 1)) irit.attrib(block1, "rgb", irit.GenStrObject("50, 100, 255")) block2 = block1 * irit.rz(180) irit.attrib(block2, "rgb", irit.GenStrObject("100, 50, 255")) # # Add the animation curves:
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Some examples of using reflection lines. # # Gershon Elber, October 1999 # save_res = irit.GetResolution() save_mat = irit.GetViewMatrix() irit.SetViewMatrix(irit.rx(2) * irit.ry(2) * irit.sc(0.5)) irit.viewobj(irit.GetViewMatrix()) irit.SetViewMatrix(save_mat) # ############################################################################ s = irit.ruledsrf( irit.ctlpt( irit.E3, (-1 ), (-1 ), 0 ) + \ irit.ctlpt( irit.E3, 1, (-1 ), 0 ), \ irit.ctlpt( irit.E3, (-1 ), 1, 0 ) + \ irit.ctlpt( irit.E3, 1, 1, 0 ) ) * irit.rx( 90 ) s = irit.sraise(irit.sraise(s, irit.ROW, 3), irit.COL, 3) s = (-irit.seditpt(s, irit.ctlpt(irit.E3, 0, 1, 0), 1, 1)) irit.color(s, irit.MAGENTA) reflectlns = irit.nil()
def antbody(): save_res = irit.GetResolution() c = irit.pcircle((0, 0, 0), 1) body = (-irit.sfromcrvs( irit.list( c * irit.sc(1e-006) * irit.ty((-0.1)) * irit.tz(0.19), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0.1)) * irit.tz(0.19), c * irit.sy(0.8) * irit.sc(0.11) * irit.ty((-0.1)) * irit.tz(0.21), c * irit.sy(0.8) * irit.sc(0.14) * irit.ty((-0.1)) * irit.tz(0.23), c * irit.sy(0.8) * irit.sc(0.14) * irit.ty((-0.1)) * irit.tz(0.26), c * irit.sy(0.8) * irit.sc(0.11) * irit.ty((-0.1)) * irit.tz(0.28), c * irit.sy(0.8) * irit.sc(0.11) * irit.ty((-0.1)) * irit.tz(0.29), c * irit.sy(0.8) * irit.sc(0.24) * irit.ty( (-0.05)) * irit.tz(0.31), c * irit.sy(0.8) * irit.sc(0.27) * irit.ty( (-0.05)) * irit.tz(0.41), c * irit.sy(0.8) * irit.sc(0.19) * irit.ty( (-0.05)) * irit.tz(0.44), c * irit.sy(0.8) * irit.sc(0.19) * irit.ty( (-0.05)) * irit.tz(0.45), c * irit.sy(0.8) * irit.sc(0.3) * irit.ty( (-0.035)) * irit.tz(0.47), c * irit.sy(0.8) * irit.sc(0.32) * irit.ty( (-0.035)) * irit.tz(0.59), c * irit.sy(0.8) * irit.sc(0.24) * irit.ty( (-0.035)) * irit.tz(0.62), c * irit.sy(0.8) * irit.sc(0.24) * irit.ty( (-0.035)) * irit.tz(0.63), c * irit.sy(0.8) * irit.sc(0.3) * irit.ty((-0.03)) * irit.tz(0.65), c * irit.sy(0.8) * irit.sc(0.28) * irit.ty( (-0.03)) * irit.tz(0.76), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0.1)) * irit.tz(0.85), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0.1)) * irit.tz(0.87), c * irit.sy(0.8) * irit.sc(0.18) * irit.ty((-0.1)) * irit.tz(0.93), c * irit.sy(0.8) * irit.sc(0.18) * irit.ty((-0.1)) * irit.tz(1.03), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0.1)) * irit.tz(1.1), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0.1)) * irit.tz(1.12), c * irit.sy(0.8) * irit.sc(0.18) * irit.ty( (-0.06)) * irit.tz(1.18), c * irit.sy(0.8) * irit.sc(0.18) * irit.ty( (-0.03)) * irit.tz(1.32), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0)) * irit.tz(1.41), c * irit.sy(0.8) * irit.sc(0.07) * irit.ty((-0)) * irit.tz(1.43), c * irit.sy(0.8) * irit.sc(0.22) * irit.ty(0.05) * irit.tz(1.5), c * irit.sy(0.8) * irit.sc(0.2) * irit.ty((-0)) * irit.tz(1.66), c * irit.sy(0.8) * irit.sc(0.05) * irit.ty( (-0.22)) * irit.tz(1.85), c * irit.sy(0.8) * irit.sc(1e-006) * irit.ty( (-0.22)) * irit.tz(1.86)), 3, irit.KV_OPEN)) irit.SetResolution(15) eye1 = irit.sphere((0, 0, 0), 0.08) * irit.rx(20) * irit.ry( (-20)) * irit.trans((0.15, 0.05, 1.59)) eye2 = eye1 * irit.sx((-1)) irit.SetResolution(20) bodycut = body / eye1 ^ eye2 irit.attrib(bodycut, "rgb", irit.GenStrObject("255,50,50")) eye1cut = eye1 / body irit.attrib(eye1cut, "reflection", irit.GenStrObject("0.85")) irit.attrib(eye1cut, "rgb", irit.GenStrObject("15,15,15")) eye2cut = eye2 / body irit.attrib(eye2cut, "reflection", irit.GenStrObject("0.85")) irit.attrib(eye2cut, "rgb", irit.GenStrObject("15,15,15")) irit.SetResolution(save_res) retval = irit.list(bodycut, irit.list(eye1cut, eye2cut)) return retval
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # Few examples of computing the art gallery solution of planar curves. # # Gershon Elber, November 2004 # view_mat1 = irit.rx( 0 ) irit.viewobj( view_mat1 ) irit.free( view_mat1 ) # # The symbolic computation below is faster this way. # iprod = irit.iritstate( "bspprodmethod", irit.GenIntObject(0) ) def randrgb( ): return ( str(irit.random( 80, 255 )) + "," + str(irit.random( 80, 155 )) + "," + str(irit.random( 80, 255 ) )) dashlist = irit.list( "[0.001 0.01] 0", "[0.015 0.01 0.001 0.01] 0", "[0.03 0.01] 0", "[0.02 0.01 0.001 0.01 0.001 0.01] 0", "[0.03 0.01 0.001 0.01] 0" )
sqr1 = irit.poly( irit.list(irit.point((-1), (-1), 1), irit.point((-1), 1, 1), irit.point(1, 1, 1), irit.point(1, (-1), 1)), irit.FALSE) sclfctr = 0.6 sqr2 = sqr1 * irit.sc((-sclfctr)) * irit.tz(sclfctr * 2) trap1 = irit.poly( irit.list( irit.point((-1), (-1), 1) * irit.sc(sclfctr), irit.point((-1), 1, 1) * irit.sc(sclfctr), irit.point((-1), 1, 1), irit.point((-1), (-1), 1)), 0) trap2 = trap1 * irit.rz(180) prim1 = irit.list(sqr1, sqr2, trap1, trap2) prim2 = prim1 * irit.rx(90) prim3 = prim1 * irit.rx((-90)) baseunitaux = irit.list(prim1, prim2, prim3, trap1 * irit.rx(90) * irit.ry((-90)), trap2 * irit.rx((-90)) * irit.ry(90)) baseunit = irit.list(baseunitaux, baseunitaux * irit.ty(2.35), irit.box( ((-0.15), 1, (-0.5)), 0.3, 0.35, 1)) * irit.sc(0.5) irit.free(baseunitaux) baseunit1 = baseunit irit.color(baseunit1, irit.RED) baseunit2 = baseunit * irit.tx(1.175) irit.color(baseunit2, irit.GREEN)
def snaket( t ): p = irit.point( 0, 0, 0 ) ct = irit.cbspline( 3, irit.list( p * \ ctx( 0 + t, 1.5 ) * \ irit.ty( 0.22 ), p * \ ctx( 0 + t, 1.5 ) * \ irit.ty( 0.22 ), p * \ ctx( 0.3 + t, 1.5 ) * \ irit.ty( 0.17 ) * \ irit.tz( 0.3 ), p * \ ctx( 2 + t, 1.5 ) * \ irit.ty( (-0.06 ) ) * \ irit.tz( 2 ), p * \ ctx( 4 + t, 1.5 ) * \ irit.ty( (-0.06 ) ) * \ irit.tz( 4 ), p * \ ctx( 6 + t, 1.5 ) * \ irit.ty( (-0.06 ) ) * \ irit.tz( 6 ), p * \ ctx( 8 + t, 2.5 ) * \ irit.ty( (-0.065 ) ) * \ irit.tz( 8 ), p * \ ctx( 10 + t, 2.5 ) * \ irit.ty( (-0.07 ) ) * \ irit.tz( 10 ), p * \ ctx( 12 + t, 2.5 ) * \ irit.ty( (-0.075 ) ) * \ irit.tz( 12 ), p * \ ctx( 14 + t, 1.5 ) * \ irit.ty( (-0.08 ) ) * \ irit.tz( 14 ), p * \ ctx( 16 + t, 1.5 ) * \ irit.ty( (-0.09 ) ) * \ irit.tz( 16 ), p * \ ctx( 18 + t, 1.5 ) * irit.ty( (-0.1 ) ) * irit.tz( 18 ), p * \ irit.ty( (-0.1 ) ) * \ irit.tz( 20 ), p * \ irit.ty( (-0.1 ) ) * \ irit.tz( 21 ) ), irit.list( irit.KV_OPEN ) ) c = irit.circle( ( 0, 0, 0 ), 0.36 ) * irit.rz( (-90 ) ) scalecrv = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0, 0.001 ), \ irit.ctlpt( irit.E2, 0.1, 0.1 ), \ irit.ctlpt( irit.E2, 0.2, 0.4 ), \ irit.ctlpt( irit.E2, 0.3, 0.7 ), \ irit.ctlpt( irit.E2, 0.4, 0.8 ), \ irit.ctlpt( irit.E2, 0.5, 0.9 ), \ irit.ctlpt( irit.E2, 0.6, 0.95 ), \ irit.ctlpt( irit.E2, 0.7, 1 ), \ irit.ctlpt( irit.E2, 0.8, 1 ) ), irit.list( irit.KV_OPEN ) ) s1 = irit.swpsclsrf( c, ct, scalecrv, irit.vector( 0, 1, 0 ), 1 ) irit.attrib( s1, "ptexture", irit.GenStrObject("snake2.gif,1,30" )) s2 = irit.sfromcrvs( irit.list( c * \ irit.ty( (-0.1 ) ) * \ irit.tz( 21 ), c * \ irit.ty( (-0.1 ) ) * \ irit.tz( 22 ), c * \ irit.ty( (-0.14 ) ) * \ irit.sx( 2.2 ) * \ irit.sy( 1.2 ) * \ irit.tz( 23 ), c * \ irit.ty( (-0.14 ) ) * \ irit.sx( 2.2 ) * \ irit.sy( 1.2 ) * \ irit.tz( 24 ), c * \ irit.sy( 0.9 ) * \ 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
#This is an IRIT script and as such requires both math and irit import: # import math import irit # # # A model of a light mill. # # Gershon Elber, Dec 1998. # circ = irit.cregion( irit.circle((0, 0, 0), 0.6) * irit.rz(90) * irit.rx(90) * irit.tz(2.1), 0.1, 1.9) bodysec = ( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, (-0.5 ), 0, 0 ), \ irit.ctlpt( irit.E3, (-0.5 ), 0, 0.01 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 0.05 ), \ irit.ctlpt( irit.E3, (-0.03 ), 0, 0.3 ), \ irit.ctlpt( irit.E3, (-0.03 ), 0, 0.75 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 1 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 1.1 ), \ irit.ctlpt( irit.E3, (-0.03 ), 0, 1.2 ), \ irit.ctlpt( irit.E3, (-0.03 ), 0, 1.3 ), \ irit.ctlpt( irit.E3, (-0.04 ), 0, 1.31 ), \ irit.ctlpt( irit.E3, (-0.08 ), 0, 1.32 ), \ irit.ctlpt( irit.E3, (-0.09 ), 0, 1.4 ), \ irit.ctlpt( irit.E3, (-0.08 ), 0, 1.5 ) ), irit.list( irit.KV_OPEN ) ) + (-circ ) + irit.cbspline( 3, irit.list( \ irit.ctlpt( irit.E3, (-0.07 ), 0, 2.7 ), \ irit.ctlpt( irit.E3, (-0.07 ), 0, 2.8 ), \
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) item1 = (itemaux2 - diagpoly - diagpoly * irit.sy((-1)) - diagpoly * irit.sz( (-1)) - diagpoly * irit.sz((-1)) * irit.sy((-1))) item1 = irit.convex(item1) irit.color(item1, irit.RED) item2 = item1 * irit.sx((-1)) irit.color(item2, irit.MAGENTA) item3 = item1 * irit.rx(90) * irit.rz(90) irit.color(item3, irit.GREEN) item4 = item1 * irit.rx(90) * irit.rz((-90)) irit.color(item4, irit.YELLOW) item5 = item1 * irit.rx(90) * irit.ry(90) irit.color(item5, irit.BLUE) item6 = item1 * irit.rx(90) * irit.ry((-90)) irit.color(item6, irit.CYAN) grp1 = irit.list(item2, item3, item5) grp2 = irit.list(item1, item4, item6) scl = irit.creparam( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E1, 1 ), \
v1 = (0.2, 0, 0) # The T Letter v2 = (0.2, 0.5, 0) v3 = (0.3, 0.5, 0) v4 = (0.3, 0.6, 0) v5 = (0, 0.6, 0) v6 = (0, 0.5, 0) v7 = (0.1, 0.5, 0) v8 = (0.1, 0, 0) t = irit.poly( irit.list( v1, v2, v3, v4, v5, v6,\ v7, v8 ), 0 ) irit.view(t, irit.ON) i1 = i * irit.rx(90) r2 = r * irit.trans((0.4, 0, 0)) * irit.rx(90) i3 = i * irit.trans((0.8, 0, 0)) * irit.rx(90) t4 = t * irit.trans((1.2, 0, 0)) * irit.rx(90) def outlinechar(char): ochar = irit.offset(char, irit.GenRealObject(-0.02), 0, 0) retval = (irit.extrude(char, (0, 0, 1), 3) - irit.extrude(ochar, (0, 0, 1.2), 3) * irit.tz((-0.1))) return retval i1outline = outlinechar(i) * irit.rx(90) r2outline = outlinechar(r) * irit.trans((0.4, 0, 0)) * irit.rx(90) i3outline = outlinechar(i) * irit.trans((0.8, 0, 0)) * irit.rx(90)
printtest("circle", irit.isgeom(pcirc, irit.GEOM_CIRCULAR, 0.01), 1) irit.free(circ) irit.free(pcirc) irit.free(line) # # Plane # pln = irit.ruledsrf( irit.ctlpt( irit.E3, 0, 0, 0 ) + \ irit.ctlpt( irit.E3, 1, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 2, 0 ) + \ irit.ctlpt( irit.E3, 1, 1, 0 ) ) printtest("plane", irit.isgeom(pln, irit.GEOM_PLANAR, 1e-010), 1) pln = pln * irit.rx(45) * irit.rz(45) * irit.tx(1) * irit.ty((-2)) printtest("plane", irit.isgeom(pln, irit.GEOM_PLANAR, 1e-010), 1) pln = irit.ruledsrf( irit.ctlpt( irit.E3, 0, 0, 0 ) + \ irit.ctlpt( irit.E3, 1, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 2, 0 ) + \ irit.ctlpt( irit.E3, 1, 1, 1 ) ) printtest("plane", irit.isgeom(pln, irit.GEOM_PLANAR, 0.001), 0) pln = irit.ruledsrf( irit.cbezier( irit.list( irit.ctlpt( irit.E3, (-1 ), 0, 10.01 ), \ irit.ctlpt( irit.E3, 0, 0.2, 10.01 ), \ irit.ctlpt( irit.E3, 1, 0, 10.01 ) ) ), irit.cbezier( irit.list( \ irit.ctlpt( irit.E3, (-1 ), 1, 10.01 ), \ irit.ctlpt( irit.E3, 0, 0.5, 10.01 ), \ irit.ctlpt( irit.E3, 1, 1, 10.01 ) ) ) ) printtest("plane", irit.isgeom(pln, irit.GEOM_PLANAR, 1e-010), 1)
# ############################################################################ s1 = irit.sbezier( irit.list( irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0.05, 0.2, 0.1 ), \ irit.ctlpt( irit.E3, 0.1, 0.05, 0.2 ) ), irit.list( \ irit.ctlpt( irit.E3, 0.1, (-0.2 ), 0 ), \ irit.ctlpt( irit.E3, 0.15, 0.05, 0.1 ), \ irit.ctlpt( irit.E3, 0.2, (-0.1 ), 0.2 ) ), irit.list( \ irit.ctlpt( irit.E3, 0.2, 0, 0 ), \ irit.ctlpt( irit.E3, 0.25, 0.2, 0.1 ), \ irit.ctlpt( irit.E3, 0.3, 0.05, 0.2 ) ) ) ) * irit.sc( 4 ) * irit.sy( 0.3 ) irit.color(s1, irit.RED) s2 = s1 * irit.rx(4) * irit.rz(2) irit.color(s2, irit.BLUE) testssi(s1, s2, 0.1) testssi(s1, s2, 0.03) s1 = s1 * irit.sy(0.1) s2 = s2 * irit.sy(0.1) irit.color(s1, irit.RED) irit.color(s2, irit.BLUE) testssi(s1, s2, 0.1) testssi(s1, s2, 0.03) # ############################################################################
# # An object that has three projections of a cross, circle and a square. # w = 0.4 cross = ( irit.ctlpt( irit.E3, 1, 0, 0 ) + \ irit.ctlpt( irit.E3, 1, w, 0 ) + \ irit.ctlpt( irit.E3, w, w, 0 ) + \ irit.ctlpt( irit.E3, w, 1, 0 ) + \ irit.ctlpt( irit.E3, 0, 1, 0 ) ) cross = (cross + cross * irit.rz(90) + cross * irit.rz(180) + cross * irit.rz(270)) s1 = irit.extrude(cross * irit.tz((-2)), (0, 0, 4), 0) irit.free(cross) s2 = irit.extrude(irit.circle((0, 0, 0), 0.999) * irit.tz((-2)), (0, 0, 4), 0) * irit.rx(90) s = s1 * s2 irit.free(s1) irit.free(s2) irit.view(irit.list(irit.GetAxes(), s), irit.ON) irit.save("crosplug", s) irit.pause() irit.free(s)
irit.free(rot_y) irit.free(trns) # # Top round. # topround = irit.poly( lj8samplecurve( irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, (-0.7 ), 7.5 ), \ irit.ctlpt( irit.E3, 0, 2.5, 8 ), \ irit.ctlpt( irit.E3, 0, 5.7, 7.5 ) ) ), 10 ) + irit.list( ( 0, 5.7, 7.2 ), ( 0, 5.2, 7.2 ), irit.point( 0, 4.9, 6.8 ), irit.point( 0, 4.9, 6 ), irit.point( 0, 0.1, 6 ), irit.point( 0, 0.1, 6.3 ), irit.point( 0, (-0.2 ), 6.3 ), irit.point( 0, (-0.7 ), 7.1 ) ), 0 ) topround = irit.extrude(topround, (2, 0, 0), 3) * irit.tx(0.001) irit.SetResolution(4) screen = irit.con2((0, 0, 0), (0, 0, (-0.15)), 0.3, 0.2, 3) * irit.rz(45) topround = (topround - screen * irit.rx(5.5) * irit.sx(3) * irit.tx(1) * irit.tz(7.65)) irit.SetResolution(20) screen = irit.ruledsrf( irit.ctlpt( irit.E3, 0.1414, 0.1414, (-0.14 ) ) + \ irit.ctlpt( irit.E3, (-0.1414 ), 0.1414, (-0.14 ) ), \ irit.ctlpt( irit.E3, 0.1414, (-0.1414 ), (-0.14 ) ) + \ irit.ctlpt( irit.E3, (-0.1414 ), (-0.1414 ), (-0.14 ) ) ) * irit.rx( 5.5 ) * irit.sx( 3 ) * irit.tx( 1 ) * irit.tz( 7.65 ) irit.attrib(screen, "rgb", irit.GenStrObject("20,100,20")) tmpbody = irit.box((1, 0.75, 6.5), 2, 3.5, 0.15) z = 7.2 while (z <= 7.5): tmpbody = tmpbody ^ irit.box(((-0.1), 1, z), 0.2, 3, 0.05) z = z + 0.1 topround = topround / tmpbody
displayobjobjmdres(s2, c4a * irit.tx((-0.5)), 1e-010) displayobjobjmdres(s2, c4a * irit.sx((-3)) * irit.tx(0.5), 1e-010) displayobjobjmdres(s2, c2a * irit.sx((-3)) * irit.tx(0.5), 1e-010) displayobjobjmdres(s2, s2 * irit.sx((-3)) * irit.tx(0.5), 1e-010) displayobjobjmdres(s2, s2 * irit.sx((-3)) * irit.tx(0.5) * irit.ry((-10)), 1e-010) displayobjobjmdres(s2, s2 * irit.sx((-3)) * irit.tx(0.5) * irit.ry(10), 1e-010) displayobjobjmdres(s3, s3 * irit.sx(3) * irit.tx(0.5) * irit.ry(10), 1e-010) displayobjobjmdres(s3 * irit.rx(90), s3 * irit.sx(3) * irit.tx(0.5) * irit.ry(10), 1e-010) displayobjobjmdres(s3 * irit.rx(90) * irit.ry(120), s3 * irit.sx(3) * irit.tx(0.5) * irit.ry(10), 1e-010) displayobjobjmdres( s3 * irit.sx(3) * irit.tx(0.5) * irit.ry((-60)) * irit.tx( (-0.5)) * irit.tz((-1.2)), s3 * irit.rx(90) * irit.ry(120), 1e-010) irit.save("min_dist", glblres) irit.view(glblres, irit.ON) # ############################################################################ irit.free(glblres)
s2 = irit.blhermite(c1, c2, d1, d2, csec1, n) irit.color(s2, irit.GREEN) s3 = irit.blhermite(c1, c2, d1, d2, csec2, n) irit.color(s3, irit.YELLOW) irit.save("blending1", irit.list(s1, s2, s3)) irit.interact(irit.list(irit.GetAxes(), s1, s2, s3)) # # Blend on a (polynomial approximation of a) sphere: # s = (-irit.surfprev( irit.cregion(irit.pcircle((0, 0, 0), 1), 0, 2) * irit.rx(90))) irit.attrprop(s, "u_resolution", irit.GenIntObject(3)) irit.attrprop(s, "v_resolution", irit.GenIntObject(3)) ds = irit.sderive(s, irit.ROW) c1 = (-irit.csurface(s, irit.ROW, 0.8)) c2 = (-irit.csurface(s, irit.ROW, 1.2)) d1 = (-irit.csurface(ds, irit.ROW, 0.8)) d2 = (-irit.csurface(ds, irit.ROW, 1.2)) s1 = irit.hermite(c1, c2, d1, d2) irit.color(s1, irit.RED) n = irit.csurface(s, irit.ROW, 1)
irit.save("nc_pckt5.itd", irit.list(cnc_ltrs.cnc, tpath)) irit.save("nc_pckt5.nc", tpath) irit.interact(irit.load("nc_pckt5.nc")) irit.free(cnc_ltrs.cnc) # ############################################################################ # # 3D contouring: A Sphere # # Add points to control the bounding box in XY. # These points have no other effect. # sp = irit.list(irit.spheresrf(5) * irit.rx(90), ((-6), (-6), 0), (6, 6, 0)) irit.color(sp, irit.RED) ofst = 0.25 baselevel = (-ofst) tpathspace = 0.2 ncpath = irit.nccntrpath(sp, ofst, baselevel, tpathspace, 0) irit.attrib(ncpath, "ncretractzlevel", irit.GenRealObject(10)) irit.attrib(ncpath, "ncmaxxybridgegap", irit.GenRealObject(0.5)) irit.interact( irit.list(irit.GetAxes() * irit.sc(6), sp, ncpath) * irit.sc(0.16)) irit.save("nc_spher.nc", ncpath)
bladetop = irit.ruledsrf(irit.cregion(sec2, 0, 0.5), (-irit.cregion(sec2, 0.5, 1))) blademain = irit.list(bladeside, bladetop) * irit.tz(0.2) irit.free(bladeside) irit.free(bladetop) bladefillet = irit.sfromcrvs( irit.list(sec1 * irit.sc(1.35) * irit.sy(1.5) * irit.tz((-0.1)), sec1, sec1 * irit.tz(0.2)), 3, irit.KV_OPEN) irit.free(sec1) irit.free(sec2) blade = irit.list(blademain, bladefillet) * irit.tx(0.1) * irit.ry( 90) * irit.sc(0.285) * irit.tx(0.636) * irit.rx(20) irit.attrib(blade, "rgb", irit.GenStrObject("128,128,128")) irit.free(blademain) irit.free(bladefillet) # # The Base # basesec = ( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0.1, 0.055 ), \ irit.ctlpt( irit.E2, 0.4, 0.052 ), \ irit.ctlpt( irit.E2, 0.435, 0.06 ), \ irit.ctlpt( irit.E2, 0.44, 0.24 ), \ irit.ctlpt( irit.E2, 0.47, 0.3 ), \ irit.ctlpt( irit.E2, 0.62, 0.29 ), \
minv = m ^ (-1) pt = m * pt1 r = math.sqrt(irit.FetchRealObject(pt * pt)) el = irit.nil() j = 0 while (j <= 360): irit.snoc( irit.point(r * math.cos(j * math.pi / 180), r * math.sin(j * math.pi / 180), 0) * minv, el) j = j + 10 retval = irit.poly(el, irit.TRUE) irit.color(retval, irit.YELLOW) return retval view_mat1 = irit.rx(0) irit.viewobj(view_mat1) irit.free(view_mat1) irit.viewstate("widthlines", 1) ri = irit.iritstate("randominit", irit.GenIntObject(1964)) # Seed-initiate the randomizer, irit.free(ri) # ############################################################################ # # Map circles using the inverse of Map3Pt2Eql, creating an bounding ellipse. # n = 40
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 # # Properly orient the Teapot in the parametric space of the Trivariate # prmdomain = irit.box( ( 0, 0, 0 ), 0.5, 1, 1 ) irit.attrib( prmdomain, "transp", irit.GenRealObject(0.8) ) teapot = teapotorig * irit.sc( 0.13 ) * irit.rz( 90 ) * irit.rx( 90 ) * irit.sx( (-1 ) ) * irit.trans( ( 0, 0.5, 0.5 ) ) all = irit.list( prmdomain, teapot ) * irit.rz( 90 ) * irit.ry( 40 ) * irit.rx( 40 ) interact( irit.list( all, irit.GetViewMatrix() ) ) irit.save( "warp1trv", all ) # # Warp the teapot, one surface at a time, after some surface refinement. # warpedteapot = irit.nil( ) i = 1 while ( i <= irit.SizeOf( teapot ) ): srf = irit.nth( teapot, i ) clr = irit.getattr( srf, "color" ) srf = irit.sreparam( irit.sreparam( srf, irit.COL, 0, 1 ), irit.ROW, 0,\
bisectsrf = irit.cbisector3d(irit.list(c1, c2), 1) display(c1, c2, bisectsrf) a = a + (-0.01) * speed a = 0 while (a <= 0.9): c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0 + a, (-1 ) ), \ irit.ctlpt( irit.E3, 0, 0 - a, 0 ), \ irit.ctlpt( irit.E3, 0, 0 + a, 1 ) ) ) bisectsrf = irit.cbisector3d(irit.list(c1, circ), 1) display(c1, circ, bisectsrf) a = a + 0.01 * speed a = 0 while (a <= 180): c1x = c1 * irit.ty((-1)) * irit.rx(a) * irit.ty(1) bisectsrf = irit.cbisector3d(irit.list(c1x, circ), 1) display(c1x, circ, bisectsrf) a = a + 2 * speed circ2 = irit.creparam(irit.pcircle((0, 0, 0), 1), 0, 1) * irit.rz( (-90)) * irit.ry(270) * irit.ty(1) irit.ffcompat(c1x, circ2) a = 0 while (a <= 1): c1 = irit.cmorph(c1x, circ2, 0, a) bisectsrf = irit.cbisector3d(irit.list(c1, circ), 1) display(c1, circ, bisectsrf) a = a + 0.01 * speed
# Case 1 # c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, (-1 ), 0, (-1 ) ), \ irit.ctlpt( irit.E3, 0, 1, (-1 ) ), \ irit.ctlpt( irit.E3, 0.3, 0, (-1 ) ), \ irit.ctlpt( irit.E3, 1, 0, (-1 ) ) ) ) c2 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, (-1 ), 0, 1 ), \ irit.ctlpt( irit.E3, 0, 1, 1 ), \ irit.ctlpt( irit.E3, 0.3, 1, 1 ), \ irit.ctlpt( irit.E3, 1, 0, 1 ) ) ) r1 = irit.ruledsrf(c1, c2) r2 = r1 * irit.rx(90) c = irit.nth( irit.rrinter(irit.cmesh(r1, irit.ROW, 0), irit.cmesh(r1, irit.ROW, 1), irit.cmesh(r2, irit.ROW, 0), irit.cmesh(r2, irit.ROW, 1), 10, 0), 1) irit.color(c, irit.RED) irit.adwidth(c, 3) irit.interact(irit.list(r1, r2, c)) zerosetsrf = irit.rrinter(irit.cmesh(r1, irit.ROW, 0), irit.cmesh(r1, irit.ROW, 1), irit.cmesh(r2, irit.ROW, 0), irit.cmesh(r2, irit.ROW, 1), 10, 1)
irit.viewobj( irit.GetViewMatrix() ) irit.SetViewMatrix( save_mat) # ############################################################################ # # Cylinder-Cylinder intersection # s1 = irit.cylinsrf( 4, 1 ) * irit.tz( (-2 ) ) irit.color( s1, irit.RED ) c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0, (-1 ) ), \ irit.ctlpt( irit.E3, 0, 0, 1 ) ) ) r1 = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 1 ) ) ) s2 = irit.cylinsrf( 4, 1 ) * irit.tz( (-2 ) ) * irit.rx( 90 ) * irit.tx( 0.5 ) irit.color( s2, irit.MAGENTA ) c2 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0.5, (-1 ), 0 ), \ irit.ctlpt( irit.E3, 0.5, 1, 0 ) ) ) r2 = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 1 ) ) ) zerosetsrf = irit.coerce( irit.gginter( c1, r1, c2, r2, 10, 1 ),\ irit.E3 ) * irit.rotx( (-90 ) ) * irit.roty( (-90 ) ) irit.SetResolution( 100) zeroset = irit.contour( zerosetsrf, irit.plane( 0, 0, 1, 0 ) ) irit.color( zeroset, irit.GREEN ) irit.adwidth( zeroset, 3 ) irit.interact( irit.list( zerosetsrf * irit.sz( 0.1 ), zeroset, irit.GetAxes() ) * irit.sc( 3 ) ) c = irit.nth( irit.gginter( c1, r1, c2, r2, 100, 0 ),\ 1 )