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 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 rigidmotionpos(cnew, c): t = irit.FetchRealObject(irit.nth(irit.pdomain(c), 1)) pos = irit.coerce(irit.ceval(c, t), irit.VECTOR_TYPE) tn = irit.ctangent(c, t, 1) retval = cnew * \ irit.rz( math.atan2( irit.FetchRealObject(irit.coord( tn, 1 )), irit.FetchRealObject(irit.coord( tn, 0 )) ) * \ 180/math.pi ) * \ irit.trans( irit.Fetch3TupleObject(pos) ) 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 antleg(): c = irit.pcircle((0, 0, 0), 0.03) * irit.ry(90) retval = (-irit.sfromcrvs( irit.list( c * irit.ty((-0.15)), 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.7) * irit.rz((-55)) * irit.tx(0.4) * irit.ty(0.15), c * irit.sc(0.8) * irit.rz((-40)) * irit.tx(0.47) * irit.ty( (-0.1)), c * irit.sc(0.8) * irit.rz((-35)) * irit.tx(0.53) * irit.ty( (-0.18)), c * irit.sc(0.65) * irit.rz((-35)) * irit.tx(0.61) * irit.ty( (-0.22)), c * irit.sc(0.75) * irit.rz((-20)) * irit.tx(0.63) * irit.ty( (-0.23)), c * irit.sc(0.75) * irit.rz((-15)) * irit.tx(0.7) * irit.ty( (-0.24)), c * irit.sc(0.001) * irit.rz((-15)) * irit.tx(0.7) * irit.ty( (-0.24))), 3, irit.KV_OPEN)) irit.attrib(retval, "rgb", irit.GenStrObject("255,50,50")) return retval
def extractcrvregion( crv, t1, t2, idx ): if ( irit.FetchRealObject(t1) < 0 ): retval = irit.cregion( crv, irit.FetchRealObject(t1) + 1, 1 ) + irit.cregion( crv, 0, irit.FetchRealObject(t2) ) else: retval = irit.cregion( crv, irit.FetchRealObject(t1), irit.FetchRealObject(t2) ) retval = irit.creparam( retval, 0, 1 ) tn = irit.vector( 1, 0, 0 ) * irit.rz( irit.FetchRealObject( idx ) ) retval = irit.list( retval * irit.trans( irit.Fetch3TupleObject( tn * irit.sc( 0.15 ) ) ), irit.arrow3d( irit.coerce( irit.ceval( retval, 0.5 ), 3 ), tn, 0.35, 0.01, 0.1, 0.02 ) ) irit.attrib( retval, "width", irit.GenRealObject( irit.random( 0.007, 0.01 ) ) ) irit.attrib( retval, "gray", irit.GenRealObject( irit.random( 0.2, 0.8 ) ) ) irit.attrib( retval, "rgb", irit.GenStrObject( str(int(irit.random( 100, 255 ) ) ) + "," + str(int(irit.random( 100, 255 ) ) ) + "," + str(int(irit.random( 100, 255 ) ) ) ) ) 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
trns = irit.trans(((-7.75), 0, (-7.45))) irit.attrib(stopper, "animation", irit.list(trns, rot_y, trns ^ (-1))) 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
# ############################################################################ 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) # ############################################################################
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)
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 ) * \ irit.trans( ( 0.66, 0, 0.7 ) ),
irit.attrib(cntrs, "dwidth", irit.GenRealObject(3)) irit.color(cntrs, irit.RED) irit.interact(irit.list(c, p, cntrs)) irit.free(c) irit.free(p) irit.free(cntrs) # # Simple self intersecting surface. # c1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, (-1 ), 0 ), \ irit.ctlpt( irit.E3, 0, 1, 0.2 ), \ irit.ctlpt( irit.E3, 1, 0, 0.4 ), \ irit.ctlpt( irit.E3, (-1 ), 0, 0.6 ) ), irit.list( irit.KV_OPEN ) ) s1 = irit.ruledsrf(c1, c1 * irit.tz(1) * irit.rz(10)) irit.color(s1, irit.GREEN) irit.SetResolution(30) # # Computing self intersection by a Boolean operation with itself - Parametric. # dummy = irit.iritstate("intercrv", irit.GenRealObject(1)) uvbool = irit.iritstate("uvboolean", irit.GenRealObject(1)) s1inter = (s1 + s1) irit.color(s1inter, irit.RED) irit.attrib(s1inter, "dwidth", irit.GenRealObject(3)) paramdomain = irit.poly(irit.list((0, 0, 0), (0, 1, 0), (2, 1, 0), (2, 0, 0)), irit.FALSE)
i = 0 while ( i <= 20 ): pt1 = irit.point( irit.random( (-0.5 ), 0.5 ), irit.random( (-0.5 ), 0.5 ), 0 ) pt2 = irit.point( irit.random( (-0.5 ), 0.5 ), irit.random( (-0.5 ), 0.5 ), 0 ) skel2dcolor( pt1, pt2, crv3, 0.001, irit.list( 0.01, (-1e-010 ) ), 1, "" ) irit.milisleep( delay ) i = i + 1 skel2dcolor( pt1, pt2, crv3, 0.001, irit.list( 0.01, (-1e-010 ) ), 1, "skel2d5" ) irit.pause( ) # ############################################################################ ln1 = ( irit.ctlpt( irit.E2, (-1 ), (-1 ) ) + \ irit.ctlpt( irit.E2, 1, (-1 ) ) ) ln2 = ln1 * irit.rz( 120 ) * irit.tx( (-0.5 ) ) * irit.ty( (-0.5 ) ) crv3 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, (-0.5 ), 0 ), \ irit.ctlpt( irit.E2, 0.4, (-1 ) ), \ irit.ctlpt( irit.E2, 0.6, 0.5 ), \ irit.ctlpt( irit.E2, 0.6, (-1 ) ) ), irit.list( irit.KV_OPEN ) ) * irit.tx( (-0.4 ) ) * irit.ty( 0.1 ) skel2dcolor( ln1, ln2, crv3, 1e-006, irit.list( 1e-007, 1e-010 ), 1, "skel2d6" ) irit.pause( ) ''' # ############################################################################ pt1 = irit.point( 0.1, 0, 0 ) crv2 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 0 ), \ irit.ctlpt( irit.E2, (-0.3 ), (-0.5 ) ), \ irit.ctlpt( irit.E2, 0.6, 1 ) ) ) crv3 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-0.5 ), (-1 ) ), \
#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 ), \
a = (-2) while (a <= 0): pt = (a, 0, 0) c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, (-0.2 ), (-1 ) ), \ irit.ctlpt( irit.E3, 0, (-3.2 ), 0 ), \ irit.ctlpt( irit.E3, 0, (-0.2 ), 1 ) ) ) bisectsrf = irit.cbisector3d(irit.list(c1, pt), 0) display(c1, pt, bisectsrf) a = a + 0.005 * speed # ############################################################################ # # A cubic # circ = irit.pcircle((0, 0, 0), 1) * irit.rz(90) * irit.ry((-90)) irit.ffcompat(c1, circ) pt = (0, 0, 0) a = 0 while (a <= 1): c1x = irit.cmorph(c1, circ, 0, a) bisectsrf = irit.cbisector3d(irit.list(c1x, pt), 0) display(c1x, pt, bisectsrf) a = a + 0.01 * speed a = 0 while (a <= 0.9): pt = (0, a, 0) bisectsrf = irit.cbisector3d(irit.list(circ, pt), 0)
# # # The Blade # sec1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, (-0.525 ), (-0.041 ), 0 ), \ irit.ctlpt( irit.E2, (-0.0935 ), 0.102 ), \ irit.ctlpt( irit.E2, 0.487, 0.14 ), \ irit.ctlpt( irit.E2, 0.882, 0.112 ), \ irit.ctlpt( irit.E2, 0.878, 0.198 ), \ irit.ctlpt( irit.E2, 0.559, 0.403 ), \ irit.ctlpt( irit.E2, (-0.183 ), 0.252 ), \ irit.ctlpt( irit.E2, (-0.525 ), (-0.04 ) ) ), irit.list( irit.KV_OPEN ) ) * irit.tx( (-0.2 ) ) * irit.ty( (-0.2 ) ) sec2 = sec1 * irit.sy(0.5) * irit.sc(1.2) * irit.tz(2.5) * irit.rz(30) bladeside = irit.ruledsrf(sec1, sec2) 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)
# # American plane's marker # d = math.pi / 180 * 360 * 2 / 5 ptc = (0, 0, 0) pt1 = (math.cos(0), math.sin(0), 0) pt2 = (math.cos(d), math.sin(d), 0) pt3 = (math.cos(d * 2), math.sin(d * 2), 0) pt4 = (math.cos(d * 3), math.sin(d * 3), 0) pt5 = (math.cos(d * 4), math.sin(d * 4), 0) star = irit.list(irit.poly(irit.list(ptc, pt1, pt2), irit.FALSE), irit.poly(irit.list(ptc, pt2, pt3), irit.FALSE), irit.poly(irit.list(ptc, pt3, pt4), irit.FALSE), irit.poly(irit.list(ptc, pt4, pt5), irit.FALSE), irit.poly(irit.list(ptc, pt5, pt1), irit.FALSE)) * irit.rz(90) irit.color(star, irit.WHITE) irit.SetResolution(80) circ = irit.circpoly((0, 0, 1), (0, 0, 0), 1) * irit.tz((-0.01)) irit.color(circ, irit.BLUE) irit.attrib(circ, "rgb", irit.GenStrObject("0,0,8")) irit.SetResolution(20) logo1 = irit.list(circ, star) irit.interact(logo1) irit.save("logo1", logo1) irit.free(logo1)
# 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" ) raypoint = ( irit.ctlpt( irit.E2, (-0.05 ), 0 ) + \ irit.ctlpt( irit.E2, 0.05, 0 ) ) raypoints = irit.list( raypoint, raypoint * irit.rz( 45 ), raypoint * irit.rz( 90 ), raypoint * irit.rz( 135 ) ) unitsquare = ( irit.ctlpt( irit.E2, 0, 0 ) + \ irit.ctlpt( irit.E2, 0, 1 ) + \ irit.ctlpt( irit.E2, 1, 1 ) + \ irit.ctlpt( irit.E2, 1, 0 ) + \ irit.ctlpt( irit.E2, 0, 0 ) ) irit.color( unitsquare, irit.MAGENTA ) irit.adwidth( unitsquare, 2 ) irit.awidth( unitsquare, 0.015 ) irit.attrib( unitsquare, "rgb", irit.GenStrObject("255,128,255") ) def apxeq( x, y ): retval = abs( irit.FetchRealObject(x - y) ) < 1e-006 return retval
# A puzzle of transparent boxes in ball inside. # # Gershon Elber, June 1996 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)
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
irit.ctlpt( irit.E2, 4.305, 0.086 ), \ irit.ctlpt( irit.E2, 5.569, (-0.845 ) ), \ irit.ctlpt( irit.E2, 6.914, (-2.508 ) ), \ irit.ctlpt( irit.E2, 11.147, (-1.629 ) ), \ irit.ctlpt( irit.E2, 8.565, (-0.453 ) ), \ irit.ctlpt( irit.E2, 4.533, 1.283 ), \ irit.ctlpt( irit.E2, 8.031, 2.972 ), \ irit.ctlpt( irit.E2, 9.304, 4.314 ), \ irit.ctlpt( irit.E2, 8.252, 6.532 ), \ irit.ctlpt( irit.E2, 5.942, 5.176 ), \ irit.ctlpt( irit.E2, 5.483, 1.597 ), \ irit.ctlpt( irit.E2, 3.427, 2.095 ) ), irit.list( irit.KV_PERIODIC ) ) * irit.sc( 0.1 ) * irit.tx( (-0.5 ) ) * irit.ty( (-0.2 ) ) crvtr = irit.cfncrvtr(c, 1000, 2, 1) crvtr2d = irit.coerce(crvtr, irit.E2) * irit.rz(90) * irit.sx( (-1)) * irit.sy(0.005) irit.color(crvtr2d, irit.YELLOW) irit.interact(irit.list(irit.GetAxes(), c, crvtr2d)) c2 = rigidmotionpos(irit.cfncrvtr(crvtr, 0.001, 3, 0), c) irit.color(c2, irit.YELLOW) irit.interact(irit.list(c, c2)) irit.save("crvtrrc1", irit.list(c, c2, crvtr)) # ############################################################################ crvtr = irit.cfncrvtr(c, 100, 2, 1)
irit.color(crvs, irit.RED) # ################################ intercrvs = irit.carrangmnt(crvs, 1e-012, 2, irit.point(0, 0, 0)) intercrvs = intercrvspaint(intercrvs) all1 = irit.list(irit.GetAxes(), intercrvs) irit.free(intercrvs) # ################################ theta = 45 while (theta >= 0): rcrvs = crvs * irit.rz(theta) * irit.tx((-0.35)) linearlowenv = irit.carrangmnt(rcrvs, 1e-009, 3, irit.GenRealObject(0)) * irit.tz((-0.2)) irit.color(linearlowenv, irit.YELLOW) irit.adwidth(linearlowenv, 3) irit.view(irit.list(irit.GetAxes(), rcrvs, linearlowenv), irit.ON) theta = theta + (-1) all2 = irit.list(irit.GetAxes(), crvs * irit.tx((-0.35)), linearlowenv) # ################################ c1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, (-0.2 ), 0.5 ), \ irit.ctlpt( irit.E2, 0.2, 0.5 ), \ irit.ctlpt( irit.E2, 0.1, 0.2 ) ), irit.list( irit.KV_PERIODIC ) ) c1 = irit.coerce(c1, irit.KV_OPEN)
# ############################################################################ # # 2D pocketing: CNC # import cnc_ltrs # # Deformed letters "CNC" # irit.color(cnc_ltrs.cnc, irit.RED) irit.view(irit.list(irit.GetAxes(), cnc_ltrs.cnc), irit.ON) tpath = irit.list( irit.ncpcktpath( cnc_ltrs.cnc * irit.rz( 90 ), 0.003, 0.005, 0.01, 0.1, 0,\ 1 ) ) * irit.rz( (-90 ) ) irit.attrib(tpath, "ncretractzlevel", irit.GenRealObject(0.5)) irit.attrib(tpath, "ncmaxxybridgegap", irit.GenRealObject(0.05)) irit.interact(irit.list(irit.GetAxes(), tpath)) 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) # ############################################################################ #
import math import irit # # # 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.ctlpt( irit.E2, 0.052, 0.229 ), \ irit.ctlpt( irit.E2, 0.047, 0.332 ) ), irit.list( irit.KV_PERIODIC ) ) c1 = irit.coerce(c1, irit.KV_OPEN) drawbiarcs(c1, 0.25, 180) drawbiarcs(c1, 0.1, 180) drawbiarcs(c1, 0.01, 180) irit.save("biarc2", irit.list(c1, irit.cbiarcs(c1, 0.01, 180))) # ###################################################### c1 = irit.cregion(irit.circle((0, 0, 0), 1), 0, 1) * irit.sc(0.25) c1 = (c1 + c1 * irit.rz(90) * irit.tx((-0.5))) * irit.tx(0.25) * irit.ty(0.5) c1 = (c1 + c1 * irit.rz(180) + irit.ctlpt(irit.E2, 0.5, 0.5)) drawbiarcs(c1, 0.25, 180) drawbiarcs(c1, 0.1, 180) drawbiarcs(c1, 1e-006, 180) irit.save("biarc3", irit.list(c1, irit.cbiarcs(c1, 0.01, 180))) # ###################################################### irit.viewstate("pllnaprx", 0) irit.viewstate("pllnaprx", 0)
stick6 = stick5 * irit.ry(180) irit.attrib(stick6, "rgb", irit.GenStrObject("255, 50, 50")) # ################################ 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"))
pt2 = irit.point(irit.random((-0.5), 0.5), irit.random((-0.5), 0.5), 0) pt3 = irit.point(irit.random((-0.5), 0.5), irit.random((-0.5), 0.5), 0) pl = irit.poly(irit.list(pt1, pt2, pt3), irit.FALSE) irit.color(pl, irit.GREEN) ellimp = irit.ellipse3pt(irit.Fetch3TupleObject(pt1), irit.Fetch3TupleObject(pt2), irit.Fetch3TupleObject(pt3), 0) ell = irit.conicsec(ellimp, 0, 0, 0) irit.color(ell, irit.YELLOW) irit.adwidth(ell, 2) i = 10 while (i <= n): m = irit.rz(i) * irit.sc(i / 360.0) * irit.tx(i / 360.0 - 1) ell2imp = irit.implctrans(1, ellimp, m) ell3imp = irit.cnc2quad(ellimp, 0.1) ell3imp = irit.implctrans(2, ell3imp, m) ell2 = irit.conicsec(ell2imp, 0, 0, 0) irit.color(ell2, irit.CYAN) irit.adwidth(ell2, 2) ell3 = irit.quadric(ell3imp) irit.color(ell3, irit.MAGENTA) all = irit.list(irit.GetAxes(), ell, ell2, ell3) irit.view(all, irit.ON) irit.milisleep(100) i = i + 10 irit.save("ellips3", all)
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,\
irit.ctlpt( irit.E3, 0, (-0.1 ) - a, 0 ), \ irit.ctlpt( irit.E3, 0, (-0.1 ), 1 ) ) ) c2 = irit.cbezier( irit.list( \ irit.ctlpt( irit.E3, (-1 ), 0.1, 0 ), \ irit.ctlpt( irit.E3, 0, 2.1, 0 ), \ irit.ctlpt( irit.E3, 1, 0.1, 0 ) ) ) bisectsrf = irit.cbisector3d(irit.list(c1, c2), 1) display(c1, c2, bisectsrf) a = a + 0.02 * speed # ############################################################################ # # A line and a circle # circ = irit.creparam(irit.pcircle((0, 0, 0), 1), 0, 1) * irit.rz( (-90)) * irit.ry(180) irit.ffcompat(c2, circ) a = 0 while (a <= 1): c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0, (-1 ) ), \ irit.ctlpt( irit.E3, 0, 0, 1 ) ) ) c2x = irit.cmorph(c2, circ, 0, a) bisectsrf = irit.cbisector3d(irit.list(c1, c2x), 1) display(c1, c2x, bisectsrf) a = a + 0.01 * speed # ############################################################################ # # A line and a circle (again) #