def drawtritangencies(srfs, orient, subtol, numtol, savename): tritans = irit.srf3tans(srfs, orient, subtol, numtol) tritansedges = evaltritangency(srfs, tritans) irit.color(tritansedges, irit.YELLOW) irit.color(srfs, irit.CYAN) if (irit.SizeOf(irit.GenStrObject(savename)) > 0): irit.save(savename, irit.list(srfs, tritansedges)) irit.interact(irit.list(srfs, tritansedges))
def drawbitangencies( srfs, orient, subtol, numtol, mergetol, merged,\ savename ): bitans = irit.srf2tans(srfs, orient, subtol, numtol, mergetol) bitansedges = evalbitangency(srfs, bitans, merged) irit.color(bitansedges, irit.YELLOW) irit.color(srfs, irit.CYAN) if (irit.SizeOf(irit.GenStrObject(savename)) > 0): irit.save(savename, irit.list(srfs, bitansedges)) irit.interact(irit.list(srfs, bitansedges))
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 cmpoffalltols(crv, header, fname, dist, tol, steps): i = 0 while (i <= steps): irit.printf("\n\n%s: tolerance = %lf, dist = %lf", irit.list(header, tol, dist)) c1 = irit.offset(crv, irit.GenRealObject(dist), tol, 0) c2 = irit.offset(crv, irit.GenRealObject(dist), tol, 1) c3 = irit.aoffset(crv, irit.GenRealObject(dist), tol, 0, 0) c4 = irit.loffset(crv, dist, 300, irit.SizeOf(c2), 4) irit.attrib(c1, "dash", irit.GenStrObject("[0.1 0.01] 0")) irit.color(c1, irit.RED) irit.attrib(c2, "dash", irit.GenStrObject("[0.01 0.01] 0")) irit.color(c2, irit.GREEN) irit.attrib(c3, "dash", irit.GenStrObject("[0.2 0.01 0.05 0.01] 0")) irit.color(c3, irit.YELLOW) irit.attrib(c4, "dash", irit.GenStrObject("[0.1 0.1 0.01 0.01] 0")) irit.color(c4, irit.CYAN) irit.save(fname + "_" + str(i + 1), irit.list(crv, c1, c2, c3, c4)) compareoffset(crv, abs(dist), c1, c2, c3, c4) tol = tol * math.sqrt(0.1) i = i + 1
def skel2dcolor( prim1, prim2, prim3, eps, mzerotols, drawall, fname ): equapt = irit.skel2dint( prim1, prim2, prim3, 100, eps, 300, mzerotols ) if ( irit.SizeOf( equapt ) > 1 ): irit.printf( "%d solutions detected\n", irit.list( irit.SizeOf( equapt ) ) ) irit.color( equapt, irit.WHITE ) irit.adwidth( prim1, 2 ) irit.adwidth( prim2, 2 ) irit.adwidth( prim3, 2 ) tans = irit.nil( ) edges = irit.nil( ) circs = irit.nil( ) i = 1 while ( i <= irit.SizeOf( equapt ) ): e = irit.nth( equapt, i ) clrs = getrandomcolors( ) clr = irit.nth( clrs, 1 ) dclr = irit.nth( clrs, 2 ) d = irit.getattr( e, "prim1pos" ) irit.snoc( d, tans ) irit.snoc( setcolor( irit.coerce( irit.getattr( e, "prim1pos" ), irit.E2 ) + irit.coerce( e, irit.E2 ), dclr ), edges ) irit.snoc( irit.getattr( e, "prim2pos" ), tans ) irit.snoc( setcolor( irit.coerce( irit.getattr( e, "prim2pos" ), irit.E2 ) + irit.coerce( e, irit.E2 ), dclr ), edges ) irit.snoc( irit.getattr( e, "prim3pos" ), tans ) irit.snoc( setcolor( irit.coerce( irit.getattr( e, "prim3pos" ), irit.E2 ) + irit.coerce( e, irit.E2 ), dclr ), edges ) irit.snoc( setcolor( irit.pcircle( irit.Fetch3TupleObject(irit.coerce( e, irit.VECTOR_TYPE )), irit.dstptpt( d, e ) ), clr ), circs ) i = i + 1 irit.color( edges, irit.MAGENTA ) irit.color( tans, irit.GREEN ) if ( drawall ): all = irit.list( prim1, prim2, prim3, edges, tans, circs,\ equapt ) else: all = irit.list( prim1, prim2, prim3, circs ) if ( irit.SizeOf( irit.GenStrObject(fname) ) > 0 ): irit.save( fname, all ) irit.view( all, irit.ON )
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
irit.interact(a2) a3 = (b2 - b1) irit.interact(a3) a4 = (b1 - b2) irit.interact(a4) icrv = irit.iritstate("intercrv", irit.GenIntObject(1)) a5 = b2 * b1 irit.interact(irit.list(a5, b1, b2)) icrv = irit.iritstate("intercrv", icrv) irit.free(icrv) irit.save( "box-box", irit.list(a1, a2 * irit.tx(10), a3 * irit.tx(20), a4 * irit.tx(30), a5 * irit.tx(40))) irit.SetViewMatrix(save_mat) irit.free(a1) irit.free(a2) irit.free(a3) irit.free(a4) irit.free(a5) irit.free(b1) irit.free(b2) irit.free(save_mat)
r2 = irit.ruledsrf(c1, c2) * irit.ry(90) irit.awidth(r2, 0.007) 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), 50, 0), 1) irit.color(c, irit.RED) irit.adwidth(c, 3) irit.awidth(c, 0.02) irit.attrib(c, "gray", irit.GenRealObject(0.5)) irit.interact(irit.list(r1, r2, c)) irit.save("rrint5a", 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), 25, 1) zerosetsrfe3 = irit.coerce(zerosetsrf, irit.E3) * irit.rotx((-90)) * irit.roty( (-90)) * irit.sz(0.02) irit.awidth(zerosetsrfe3, 0.007) zeroset = irit.contour(zerosetsrfe3, irit.plane(0, 0, 1, 1e-005)) irit.color(zeroset, irit.RED) irit.adwidth(zeroset, 3) irit.awidth(zeroset, 0.02) irit.interact(irit.list(genaxes, zerosetsrfe3, zeroset))
irit.cnvrtpolytoptlist( \ irit.cnvrtcrvtopolygon( backcross, 50, 0 ) \ ) + \ backcrosspts, 0 \ ), \ ( 0, 2, 0 ), \ 3 \ ) - \ irit.extrude( \ irit.cnvrtcrvtopolygon( heartcross, 50, 0 ), \ ( 0, (-2 ), 0 ), \ 3 \ ) \ ) * irit.ty( 189 ) irit.attrib(back, "rgb", irit.GenStrObject("244,164,96")) irit.free(backcrosspts) irit.free(heartcross) irit.free(backcross) all = irit.list(legs, skel, cover, back) irit.free(back) irit.free(cover) irit.free(skel) irit.free(legs) irit.view(all, irit.ON) irit.pause() irit.save("bed", all) irit.free(all)
pt2 = irit.point(0.4, 0.2, 0) irit.color(c1, irit.RED) irit.adwidth(c1, 3) irit.color(pt2, irit.RED) irit.adwidth(pt2, 3) t = 0 while (t <= 1): bisectcrv = irit.calphasector(irit.list(c1, pt2), t) irit.color(bisectcrv, irit.GREEN) irit.view(irit.list(c1, pt2, bisectcrv), irit.ON) t = t + 0.03 irit.save( "asect2d1", irit.list(c1, pt2, irit.calphasector(irit.list(c1, pt2), 0.1), irit.calphasector(irit.list(c1, pt2), 0.5), irit.calphasector(irit.list(c1, pt2), 1))) irit.pause() # ############################################################################ # # A point and a cubic curve in the XY plane # c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-0.9 ), (-0.1 ) ), \ irit.ctlpt( irit.E2, (-1.3 ), (-1.3 ) ), \ irit.ctlpt( irit.E2, 1.3, 0.3 ), \ irit.ctlpt( irit.E2, 0.3, 1 ) ) ) pt2 = irit.point((-0.5), 0.5, 0) irit.color(c1, irit.RED)
s5 = (t8 + t9) irit.free(t8) irit.free(t9) irit.view(s5, irit.OFF) s6 = (s4 - s5) irit.free(s4) irit.free(s5) final = irit.convex(s6) irit.free(s6) irit.printf("total time = %f\n", irit.list(irit.time(0))) # In Seconds irit.save("solid2h", final) irit.interact(final) final2 = irit.triangl(final, 1) # Convert to triangles irit.save("solid2ht", final2) irit.interact(final2) irit.free(final) irit.free(final2) irit.SetViewMatrix(save_mat) irit.SetResolution(save_res) psort = irit.iritstate("polysort", psort)
irit.adwidth(chc0, 2) irit.interact(irit.list(c0, chc0)) chc1 = irit.cnvxhull(c1, 10) irit.color(chc1, irit.GREEN) irit.adwidth(chc1, 2) irit.interact(irit.list(c1, chc1)) chc2 = irit.cnvxhull(c2, 10) irit.color(chc2, irit.GREEN) irit.adwidth(chc2, 2) irit.interact(irit.list(c2, chc2)) irit.save( "ffcnvhl1", irit.list(irit.list(c0, chc0), irit.list(c1, chc1) * irit.tx(3), irit.list(c2, chc2) * irit.tx(6))) # Discrete case works on loops as well: l = irit.nil() numpts = 30 i = 0 while (i <= numpts): irit.snoc(irit.vector(irit.random((-1), 1), irit.random((-1), 1), 0), l) i = i + 1 p = irit.poly(l, irit.FALSE) irit.color(p, irit.RED) irit.adwidth(p, 5)
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 doms = dominos(irit.circle((0, 0, 0), 1), 1.5, 0.1) irit.view(irit.list(irit.GetAxes(), doms), irit.ON) irit.pause() irit.save("dominos", doms) irit.free(doms)
mov_x = irit.creparam( irit.cbspline( 2, irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, (-2 ) ) ), irit.list( irit.KV_OPEN ) ), 10, 11 ) irit.attrib(block1, "animation", mov_x) irit.free(mov_x) mov_x = irit.creparam( irit.cbspline( 2, irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 2 ) ), irit.list( irit.KV_OPEN ) ), 10, 11 ) irit.attrib(block2, "animation", mov_x) irit.free(mov_x) # ################################ all = irit.list( stick1, stick2, stick3, stick4, stick5, stick6,\ bar1, bar2, bar3, bar4, block1, block2 ) irit.interact(all) irit.save("puz_cube", all) irit.free(stick1) irit.free(stick2) irit.free(stick3) irit.free(stick4) irit.free(stick5) irit.free(stick6) irit.free(bar1) irit.free(bar2) irit.free(bar3) irit.free(bar4) irit.free(block1) irit.free(block2) irit.free(all)
irit.ctlpt( irit.E2, 0.435, (-0.06 ) ), \ irit.ctlpt( irit.E2, 0.4, (-0.052 ) ), \ irit.ctlpt( irit.E2, 0.1, (-0.055 ) ), \ irit.ctlpt( irit.E2, 0.1, (-0.055 ) ) ), irit.list( irit.KV_OPEN ) ) + \ irit.ctlpt( irit.E2, 0.1, 0.055 ) ) base = irit.surfrev((-basesec) * irit.rx(90)) irit.free(basesec) # # Place n blade on the base: # n = 30 blades = irit.nil() i = 1 while (i <= n): irit.snoc(blade * irit.rz(360 * i / n), blades) i = i + 1 irit.free(blade) all = irit.list(base, blades) irit.free(base) irit.free(blades) irit.save("turbine", all) irit.view(all, irit.ON) irit.pause() irit.free(all)
irit.view(s4, irit.ON) irit.SetResolution(64) t4 = irit.sphere((0, 0, 0), 1) s5 = (t4 - s4) irit.free(s4) irit.free(t4) final = irit.convex(s5) irit.free(s5) irit.printf("total time = %f\n", irit.list(irit.time(0))) # In Seconds irit.interact(final) irit.save("solid4", final) # Now make the box cut out of it: t5 = irit.box(((-0.01), (-0.01), (-0.01)), 1.5, 1.5, 1.5) cut = (final - t5) cut = irit.convex(cut) irit.free(final) irit.free(t5) irit.save("solid4c", cut) irit.free(cut) irit.SetResolution(save_res)
irit.color( srf3, 14 ) irit.interact( irit.list( irit.GetAxes(), wirebox3( size * 16/2.0 ), srf1, srf2, srf3 ) ) size = 0.12 srf1 = irit.mrchcube( irit.list( tv, 1, 2, 1 ), ( size, size, size ), 4, 0.25 ) irit.color( srf1, 5 ) srf2 = irit.mrchcube( irit.list( tv, 1, 2, 1 ), ( size, size, size ), 4, 0.5 ) irit.color( srf2, 2 ) srf3 = irit.mrchcube( irit.list( tv, 1, 2, 1 ), ( size, size, size ), 4, 0.75 ) irit.color( srf3, 14 ) irit.interact( irit.list( irit.GetAxes(), wirebox3( size * 16/4.0 ), srf1, srf2, srf3 ) ) irit.free( tv ) irit.save( "mrchcub1", irit.list( irit.GetAxes(), wirebox3( size * ( 16 - 1 )/4.0 ), srf1, srf2, srf3 ) ) # # marching cubes of volume data: # size = 0.03 srf1 = irit.mrchcube( irit.list( "../data/3dhead.32", 1, 32, 32, 13 ), ( size, size, size ), 1, 500 ) irit.color( srf1, 5 ) srf2 = irit.mrchcube( irit.list( "../data/3dhead.32", 1, 32, 32, 13 ), ( size, size, size ), 1, 150 ) irit.color( srf2, 2 ) irit.interact( irit.list( irit.GetAxes(), wirebox( size * 32, size * 32, size * 13 ), srf1, srf2 ) ) size = 0.06 srf1 = irit.mrchcube( irit.list( "../data/3dhead.32", 1, 32, 32, 13 ), ( size, size, size ), 2, 500 )
intrcrv = irit.iritstate("intercrv", irit.GenIntObject(1)) i = (-0.9) while (i <= 2.9): p = irit.circpoly((0, 0, 1), (0, 0, i), 6) c = a * p irit.viewobj(c) irit.snoc(c, cntrs) i = i + 0.1 intrcrv = irit.iritstate("intercrv", intrcrv) irit.viewremove("c") irit.viewobj(cntrs) irit.pause() irit.save("contour1", cntrs) # ############################################################################ irit.SetResolution(50) view_mat1 = irit.GetViewMatrix() * irit.sc(0.9) x = irit.sphere((0, 0, 0), 1) irit.color(x, irit.RED) irit.view(irit.list(view_mat1, irit.GetAxes(), x), irit.ON) allcntrs = irit.nil() l = (-0.95) while (l <= 0.99): c = irit.contour(
irit.adwidth(c123, 3) all = irit.list(c123, c1, c2, c3) irit.SetViewMatrix(irit.sc(1.1)) irit.viewobj(irit.GetViewMatrix()) tr = 0.4 proj1 = all * irit.trans(((-tr), tr, 0)) proj2 = all * irit.rotx(90) * irit.trans((tr, tr, 0)) proj3 = all * irit.roty(90) * irit.trans(((-tr), (-tr), 0)) proj4 = all * irit.roty(30) * irit.rotx(20) * irit.trans((tr, (-tr), 0)) allproj = irit.list(proj1, proj2, proj3, proj4) irit.save("cylin3a", allproj) irit.interact(allproj) c123a = c123 * irit.roty(30) * irit.rotx(20) * irit.scale((3, 3, 3)) irit.attrib(c123a, "width", irit.GenRealObject(0.015)) irit.save("cylin3b", c123a) irit.interact(c123a) c123b = c123 * irit.roty(60) * irit.rotx(65) * irit.scale((3, 3, 3)) irit.attrib(c123b, "width", irit.GenRealObject(0.015)) irit.save("cylin3c", c123b) irit.interact(c123b) irit.SetViewMatrix(save_mat) irit.SetResolution(save_res)
s2 = (s1 - b2) irit.free(s1) irit.free(b2) irit.color(s2, irit.YELLOW) irit.view(s2, irit.ON) c2 = irit.cylin((0, (-0.4), 0.595), (0, 0.8, 0), 0.3, 3) irit.view(c2, irit.OFF) s3 = (s2 - c2) irit.free(s2) irit.free(c2) final = irit.convex(s3) irit.free(s3) irit.interact(final) tfinal = irit.triangl(final, 1) irit.interact(tfinal) efinal = irit.maxedgelen(tfinal, 0.2) irit.interact(efinal) irit.save("solid8", efinal) irit.free(final) irit.free(tfinal) irit.free(efinal) irit.SetResolution(save_res) irit.SetViewMatrix(save_mat)
glass1 = irit.surfrev(gcross) irit.interact(irit.list(gcross, irit.GetAxes(), glass1)) glass2 = irit.surfrev2(gcross, 45, 180) irit.interact(irit.list(gcross, irit.GetAxes(), glass2)) glass3 = irit.surfrevaxs(gcross, (1, 0, 1)) irit.interact(irit.list(gcross, irit.GetAxes(), glass3)) glass4 = irit.surfrevax2(gcross, 45, 315, (1, 0, 0)) irit.interact(irit.list(gcross, irit.GetAxes(), glass4)) irit.free(gcross) irit.save( "surfrev", irit.list( t1, t2, t3, t4, glass1, glass2,\ glass3, glass4 ) ) # ############################################################################ irit.SetResolution(save_res) irit.free(t1) irit.free(t2) irit.free(t3) irit.free(t4) irit.free(glass1) irit.free(glass2) irit.free(glass3) irit.free(glass4)
printtest("symbprod", irit.symbprod(s2, s2), irit.coerce(irit.symbprod(ms2, ms2), irit.SURFACE_TYPE)) printtest("symbprod", irit.symbprod(s1, s2), irit.coerce(irit.symbprod(ms1, ms2), irit.SURFACE_TYPE)) printtest("symbprod", irit.symbprod(c1, c1), irit.coerce(irit.symbprod(mc1, mc1), irit.CURVE_TYPE)) printtest("symbprod", irit.symbprod(c2, c2), irit.coerce(irit.symbprod(mc2, mc2), irit.CURVE_TYPE)) printtest("symbprod", irit.symbprod(c1, c2), irit.coerce(irit.symbprod(mc1, mc2), irit.CURVE_TYPE)) irit.save( "multivr2", irit.list(irit.mraise(mc2, 0, 5), irit.mraise(ms2, 4, 5), irit.mraise(mt1, 2, 5), irit.mraise(mt2, 3, 6), irit.mmerge(ms1, ms1, 0, 0), irit.symbdiff(mc2, mc2), irit.symbdiff(ms1, ms2), irit.symbprod(ms1, ms2), irit.symbprod(ms1, ms1))) # # Examine MZERO # s1 = irit.bivariate2bezier("math.pow(x, 2) + math.pow(y, 2) - 1", 2, 2) s1 = irit.coerce( irit.sregion( irit.sregion( s1, irit.COL, (-3 ), 3 ), irit.ROW, (-3 ),\ 3 ), irit.MULTIVAR_TYPE ) s2 = irit.bivariate2bezier("math.pow((x + 1), 2) + math.pow(y, 2) - 1", 2, 2) s2 = irit.coerce( irit.sregion( irit.sregion( s2, irit.COL, (-3 ), 3 ), irit.ROW, (-3 ),\ 3 ), irit.MULTIVAR_TYPE )
rot_y = irit.creparam( irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 90 ) ) ), 8, 9 ) irit.attrib(stage9, "animation", irit.list(rot_y)) irit.free(rot_y) irit.free(stage8) stage10 = irit.list(cubeat(0, 0, 0), cubeat((-size), 0, 0), cubeat((-size), 0, size), cubeat((-size), 0, 2 * size), stage9 * irit.trans(((-size), (-size), 2 * size))) rot_y = irit.creparam( irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, (-90 ) ) ) ), 9, 10 ) irit.attrib(stage10, "animation", irit.list(rot_y)) irit.free(rot_y) irit.free(stage9) stage11 = irit.list(cubeat(0, 0, 0), cubeat(size, 0, 0), cubeat(2 * size, 0, 0), stage10 * irit.trans((2 * size, (-size), 0))) all = irit.list(cubebbox, stage11 * irit.trans((0.5 * size, 2.5 * size, 0.5 * size))) irit.view(all, irit.ON) irit.free(stage10) irit.free(stage11) irit.save("puz3cube", all) irit.pause() irit.free(all) irit.free(cubebbox)
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,\ 1 ) srf = irit.srefine( irit.srefine( srf, irit.COL, 0, irit.list( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6,\ 0.7, 0.8, 0.9 ) ), irit.ROW, 0, irit.list( 0.1, 0.2, 0.3, 0.4, 0.5, 0.6,\ 0.7, 0.8, 0.9 ) ) irit.attrib( srf, "color", clr )
irit.ctlpt( irit.E2, 1.3, 0.05 ) ) ) * irit.sy( 0.2 ) crv2a = irit.cbezier( irit.list( \ irit.ctlpt( irit.E1, (-0.2 ) ), \ irit.ctlpt( irit.E2, 0.25, 1.9 ), \ irit.ctlpt( irit.E2, 1.3, 0.05 ) ) ) * irit.ty( 0.3 ) * irit.sx( 1.5 ) crv1b = irit.cbezier( irit.list( \ irit.ctlpt( irit.E2, 0.2, (-0.5 ) ), \ irit.ctlpt( irit.E2, 0.5, 4 ), \ irit.ctlpt( irit.E2, 1.3, (-0.45 ) ) ) ) * irit.sy( 0.2 ) crv2b = irit.cbezier( irit.list( \ irit.ctlpt( irit.E2, (-0 ), (-0.5 ) ), \ irit.ctlpt( irit.E2, 0.25, 1.09 ), \ irit.ctlpt( irit.E2, 1.1, (-0.5 ) ) ) ) * irit.ty( 0.3 ) * irit.sx( 1.5 ) irit.save( "dist2ff1", irit.list(testccdistfunc(crv1a, crv2a, irit.nil()), testccdistfunc(crv1a, crv2a, irit.list(0.5)), testccdistfunc(crv1b, crv2b, irit.nil()), testccdistfunc(crv1b, crv2b, irit.list(0.5)))) irit.free(crv1a) irit.free(crv2a) irit.free(crv1b) irit.free(crv2b) # ############################################################################ crv1a = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0.2 ), \ irit.ctlpt( irit.E2, 0.95, 3.6 ), \
irit.color( q2, irit.CYAN ) irit.printf( "%d quadratic segements\n", irit.list( irit.SizeOf( q2 ) ) ) q3 = irit.cubiccrvs( crv, 0.02, (-1 ) ) irit.color( q3, irit.MAGENTA ) irit.printf( "%d cubic segements\n", irit.list( irit.SizeOf( q3 ) ) ) q4 = irit.cubiccrvs( crv, 0.1, (-1 ) ) irit.color( q4, irit.GREEN ) irit.printf( "%d cubic segements\n", irit.list( irit.SizeOf( q4 ) ) ) all = irit.list( crv, q1 * irit.tz( 0.1 ), q2 * irit.tz( 0.2 ), q3 * irit.tz( 0.3 ), q4 * irit.tz( 0.4 ) ) irit.interact( all ) irit.save( "pp1apprx", all ) # ################################ crv = irit.cbspline( 5, irit.list( irit.ctlpt( irit.E2, 0.5, (-1 ) ), \ irit.ctlpt( irit.E2, (-1.5 ), (-0.5 ) ), \ irit.ctlpt( irit.E2, 0.5, 0 ), \ irit.ctlpt( irit.E2, (-0.15 ), 2 ), \ irit.ctlpt( irit.E2, (-1.5 ), 2 ), \ irit.ctlpt( irit.E2, (-0.5 ), 1 ), \ irit.ctlpt( irit.E2, 0.5, 2 ) ), irit.list( irit.KV_OPEN ) ) irit.color( crv, irit.WHITE ) irit.attrib( crv, "width", irit.GenRealObject(0.02 )) q1 = irit.quadcrvs( crv, 0.02, (-1 ) ) irit.color( q1, irit.YELLOW )
c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 0 ), \ irit.ctlpt( irit.E2, (-1 ), 0.1 ), \ irit.ctlpt( irit.E2, (-0.9 ), (-0.1 ) ), \ irit.ctlpt( irit.E2, 0.9, 0 ) ) ) irit.color( c1, irit.MAGENTA ) pts = irit.ffptdist( c1, 0, 1000 ) e2pts = irit.nil( ) i = 1 while ( i <= irit.SizeOf( pts ) ): pt = irit.ceval( c1, irit.FetchRealObject(irit.coord( irit.nth( pts, i ), 0 ) )) irit.snoc( pt, e2pts ) i = i + 10 irit.interact( irit.list( e2pts, c1 ) ) irit.save( "ffptdst1", irit.list( e2pts, c1 ) ) pts = irit.ffptdist( c1, 1, 1000 ) e2pts = irit.nil( ) i = 1 while ( i <= irit.SizeOf( pts ) ): pt = irit.ceval( c1, irit.FetchRealObject(irit.coord( irit.nth( pts, i ), 0 ) )) irit.snoc( pt, e2pts ) i = i + 10 irit.interact( irit.list( e2pts, c1 ) ) irit.save( "ffptdst2", irit.list( e2pts, c1 ) ) c2 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, (-0.8 ), 0 ), \ irit.ctlpt( irit.E2, (-1 ), 0.5 ), \ irit.ctlpt( irit.E2, (-0.8 ), (-0.5 ) ), \
irit.ctlpt( irit.E2, 0.00856, (-0.84 ) ), \ irit.ctlpt( irit.E2, 0.327, (-0.704 ) ), \ irit.ctlpt( irit.E2, 0.147, (-0.109 ) ), \ irit.ctlpt( irit.E2, 0.33, (-0.0551 ) ), \ irit.ctlpt( irit.E2, 0.486, 0.142 ), \ irit.ctlpt( irit.E2, 0.393, 0.623 ) ), irit.list( irit.KV_PERIODIC ) ) c2 = irit.coerce(c2, irit.KV_OPEN) irit.color(c2, irit.YELLOW) r = 0.1 pts = irit.crc2crvtan(c1, c2, r, 1e-006) ptsdsp = displayptscrctan2crvs(pts, r, c1, c2) irit.interact(irit.list(c1, c2, ptsdsp)) irit.save("crv1tan", irit.list(c1, c2, ptsdsp)) r = 0.2 pts = irit.crc2crvtan(c1, c2, r, 1e-006) ptsdsp = displayptscrctan2crvs(pts, r, c1, c2) irit.interact(irit.list(c1, c2, ptsdsp)) r = 0.4 pts = irit.crc2crvtan(c1, c2, r, 1e-006) ptsdsp = displayptscrctan2crvs(pts, r, c1, c2) irit.interact(irit.list(c1, c2, ptsdsp)) r = 1 pts = irit.crc2crvtan(c1, c2, r, 1e-006)
angle = 18 while ( angle < 19.4 ): irit.printf( "angle = %.2f\n", irit.list( angle ) ) irit.view( irit.list( ppl, gammakernelpolysrfs( pl, angle, 2 ) * irit.sz( (-1 ) ) ), irit.ON ) angle = angle + 0.1 irit.pause( ) # ############################################################################ pl = irit.poly( irit.list( ( 0.9, 0, 0 ), ( 0, (-0.9 ), 0 ), irit.point( (-0.8 ), 0, 0 ), irit.point( (-0.5 ), 0, 0 ), irit.point( 0, 1, 0 ), irit.point( 0.5, 0, 0 ) ), irit.FALSE ) ppl = plgntoplln( pl ) irit.interact( irit.list( irit.GetAxes(), ppl, gammakernelpolysrfs( pl, 25, 2 ) * irit.sz( (-1 ) ) ) ) irit.save( "gama1krn", irit.list( ppl, gammakernelpolysrfs( pl, 25, 2 ) * irit.sz( (-1 ) ) ) ) angle = 21 while ( angle < 22.6 ): irit.printf( "angle = %.2f\n", irit.list( angle ) ) irit.view( irit.list( ppl, gammakernelpolysrfs( pl, angle, 2 ) * irit.sz( (-1 ) ) ), irit.ON ) angle = angle + 0.1 irit.free( pl ) irit.free( ppl ) irit.pause( ) # ############################################################################ #
rot_cubes = cubes * irit.rotx(30) * irit.rotz(25) intrcrv = irit.iritstate("intercrv", irit.GenIntObject(1)) crvs_cubes = (cubes + rot_cubes) irit.color(crvs_cubes, irit.GREEN) irit.interact(irit.list(crvs_cubes, cubes, rot_cubes)) irit.free(crvs_cubes) intrcrv = irit.iritstate("intercrv", intrcrv) irit.free(intrcrv) u_cubes = (cubes + rot_cubes) irit.interact(u_cubes) i_cubes = cubes * rot_cubes irit.interact(i_cubes) s_cubes = (cubes - rot_cubes) irit.interact(s_cubes) irit.SetViewMatrix(irit.rotx(0)) u_cubes = irit.convex(u_cubes) i_cubes = irit.convex(i_cubes) s_cubes = irit.convex(s_cubes) irit.save("cubes_u", u_cubes) irit.save("cubes_i", i_cubes) irit.save("cubes_s", s_cubes) irit.SetViewMatrix(save_mat)