def srfframecrvs(srf, width): umin = irit.nth(irit.pdomain(srf), 1) umax = irit.nth(irit.pdomain(srf), 2) vmin = irit.nth(irit.pdomain(srf), 3) vmax = irit.nth(irit.pdomain(srf), 4) retval = irit.list( irit.swpcircsrf( irit.csurface(srf, irit.COL, irit.FetchRealObject(umin)), width, 0), irit.swpcircsrf( irit.csurface(srf, irit.COL, irit.FetchRealObject((umin + umax) / 2.0)), width, 0), irit.swpcircsrf( irit.csurface(srf, irit.COL, irit.FetchRealObject(umax)), width, 0), irit.swpcircsrf( irit.csurface(srf, irit.ROW, irit.FetchRealObject(vmin)), width, 0), irit.swpcircsrf( irit.csurface(srf, irit.ROW, irit.FetchRealObject((vmin + vmax) / 2.0)), width, 0), irit.swpcircsrf( irit.csurface(srf, irit.ROW, irit.FetchRealObject(vmax)), width, 0)) return retval
def subdivtodepth(tsrf, dpth, vu, vv): if (dpth <= 0): retval = tsrf else: if (dpth / 2.0 != math.floor(dpth / 2.0)): v = vu * (2 ^ (dpth - 1)) umin = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 1)) umax = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 2)) tsrfs = irit.sdivide(tsrf, irit.COL, umin * 0.4999 + umax * 0.5001) else: v = vv * (2 ^ (dpth - 1)) vmin = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 3)) vmax = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 4)) tsrfs = irit.sdivide(tsrf, irit.ROW, vmin * 0.4999 + vmax * 0.5001) if (irit.SizeOf(tsrfs) == 2): retval = irit.list( subdivtodepth( irit.nth( tsrfs, 1 ) * \ irit.trans( irit.Fetch3TupleObject(-v) ), dpth - 1, vu, vv ), subdivtodepth( irit.nth( tsrfs, 2 ) * \ irit.trans( irit.Fetch3TupleObject(v) ), dpth - 1, vu, vv ) ) else: retval = subdivtodepth(irit.nth(tsrfs, 1), dpth - 1, vu, vv) return retval
def lj8samplecurve(crv, n): ptl = irit.nil() t0 = irit.nth(irit.pdomain(crv), 1) t1 = irit.nth(irit.pdomain(crv), 2) if (n < 2): n = 2 dt = (t1 - t0) / (n + 0.0001 - 1) t = t0 while (t <= t1): pt = irit.ceval(crv, irit.FetchRealObject(t)) irit.snoc(pt, ptl) t = t + dt retval = ptl 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 tagcurve(crv, n, len): tmin = irit.FetchRealObject(irit.coord(irit.pdomain(crv), 1)) tmax = irit.FetchRealObject(irit.coord(irit.pdomain(crv), 2)) dt = (tmax - tmin) / float(n - 1) retval = irit.nil() t = tmin i = 1 while (i <= n): pt = irit.coerce(irit.ceval(crv, t), irit.POINT_TYPE) nrml = irit.coerce(irit.cnormal(crv, t), irit.VECTOR_TYPE) irit.snoc( irit.coerce(pt - nrml * len, irit.E2) + irit.coerce(pt + nrml * len, irit.E2), retval) t = t + dt i = i + 1 return retval
def dominos(path, scl, piecetimestep): retval = irit.nil() animtime = 0 dominopiece = irit.box( (-0.01, -0.006, 0), 0.02, 0.006, 0.05) * irit.sc(scl) rot_x = irit.cbezier( irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 80 ) ) ) crvdomain = irit.pdomain(path) t = irit.FetchRealObject(irit.nth(crvdomain, 1)) dpath = irit.cderive(path) while (t < irit.FetchRealObject(irit.nth(crvdomain, 2))): d = irit.Fetch3TupleObject( irit.coerce(irit.ceval(dpath, t), irit.POINT_TYPE)) dlen = math.sqrt(DotProd(d, d)) rot_x = irit.creparam(rot_x, animtime, animtime + piecetimestep) irit.attrib(dominopiece, "animation", irit.list(rot_x)) irit.setname(irit.getattr(dominopiece, "animation"), 0, "rot_x") dp = dominopiece * irit.rz( -math.atan2(d[0], d[1]) * 180 / math.pi) * irit.trans( irit.Fetch3TupleObject( irit.coerce(irit.ceval(path, t), irit.VECTOR_TYPE))) irit.snoc(dp, retval) t = t + 0.04 * scl / dlen animtime = animtime + piecetimestep * 0.6 return retval
def buildoffsetvisibilitymap( c, step, ofst ): retval = irit.nil( ) co = irit.offset( c, irit.GenRealObject(ofst), 1e-006, 1 ) tmin = irit.nth( irit.pdomain( co ), 1 ) tmax = irit.nth( irit.pdomain( co ), 2 ) t = tmin while ( t <= tmax ): pt = irit.coerce( irit.ceval( co, irit.FetchRealObject(t) ), irit.POINT_TYPE ) * \ irit.tz( 1 ) crvs = irit.cvisible( c, irit.Fetch3TupleObject(pt) , 1e-005 ) crvdmn = cnvrtcrvs2domains( crvs, t ) irit.attrib( crvdmn, "width", irit.GenRealObject(0.01) ) irit.attrib( crvdmn, "gray", irit.GenRealObject(0.5) ) irit.attrib( crvdmn, "rgb", irit.GenStrObject("128, 128, 255" )) irit.snoc( crvdmn, retval ) t = t + step return retval
def cnvrtcrvs2domains( crvs, theta ): retval = irit.nil( ) i = 1 while ( i <= irit.SizeOf( crvs ) ): dm = irit.pdomain( irit.nth( crvs, i ) ) irit.snoc( irit.ctlpt( irit.E2, theta, irit.nth( dm, 1 ) ) + \ irit.ctlpt( irit.E2, theta, irit.nth( dm, 2 ) ), retval ) i = i + 1 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 comparecurvaturecrvevals(c): c = irit.coerce(c, irit.KV_OPEN) tmin = irit.FetchRealObject(irit.nth(irit.pdomain(c), 1)) tmax = irit.FetchRealObject(irit.nth(irit.pdomain(c), 2)) t = tmin dt = (tmax - tmin) / 100.0 crvtrcrv = irit.cnrmlcrv(c) while (t <= tmax): kn = irit.ceval(crvtrcrv, t) k1 = math.sqrt( irit.FetchRealObject( irit.coerce(kn, irit.VECTOR_TYPE) * irit.coerce(kn, irit.VECTOR_TYPE))) k2 = irit.FetchRealObject(irit.ccrvtreval(c, t)) if (abs(k1 - k2) > 1e-05): irit.printf( "mismatch in curve curvature evaluation (%.13f vs. %.13f)\n", irit.list(k1, k2)) t = t + dt
def crvlength(crv, n): retval = 0 pd = irit.pdomain(crv) t1 = irit.nth(pd, 1) t2 = irit.nth(pd, 2) dt = (t2 - t1) / n pt1 = irit.coerce(irit.ceval(crv, irit.FetchRealObject(t1)), irit.E3) i = 1 while (i <= n): pt2 = irit.coerce( irit.ceval(crv, irit.FetchRealObject(t1) + irit.FetchRealObject(dt) * i), irit.E3) retval = retval + distptpt(pt1, pt2) pt1 = pt2 i = i + 1 return retval
morphpage(page1, page2, 0.1) morphpage(page2, page3, 0.1) morphpage(page3, page4, 0.1) morphpage(page4, page5, 0.1) morphpage(page5, page6, 0.1) i = 1 while (i <= irit.SizeOf(srfmorphlist)): irit.view(irit.nth(srfmorphlist, i), irit.ON) i = i + 1 irit.free(srfmorphlist) tv1 = irit.tfromsrfs( irit.list( page1, page2, page3, page4, page5, page6 ),\ 3, irit.KV_OPEN ) irit.interact(tv1) wmin = irit.FetchRealObject(irit.nth(irit.pdomain(tv1), 5)) wmax = irit.FetchRealObject(irit.nth(irit.pdomain(tv1), 6)) i = 0 while (i <= 100): irit.view( irit.strivar(tv1, irit.DEPTH, (wmin * (100 - i) + wmax * i) / 100), irit.ON) i = i + 1 tv1 = irit.tfromsrfs( irit.list( page1, page2, page3, page4, page5, page6 ),\ 4, irit.KV_OPEN ) irit.interact(tv1) wmin = irit.FetchRealObject(irit.nth(irit.pdomain(tv1), 5)) wmax = irit.FetchRealObject(irit.nth(irit.pdomain(tv1), 6)) i = 0 while (i <= 100):
crv2 = irit.cbspline( 5, irit.list( irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 0 ), \ irit.ctlpt( irit.E1, 1 ) ), irit.list( irit.KV_OPEN ) ) cbsp = irit.compose(crv1, crv2) irit.free(crv1) irit.free(crv2) steps = 8 pt_lst = irit.nil() i = 0 while (i <= steps - 1): pt = irit.ceval( cbsp, irit.FetchRealObject(irit.nth(irit.pdomain(cbsp), 2)) * i / (steps - 1)) irit.snoc(pt, pt_lst) i = i + 1 cpl = irit.poly(pt_lst, irit.TRUE) irit.color(cpl, irit.GREEN) irit.SetResolution(0.02) cbsp2 = cbsp cpl2 = irit.gpolyline(cbsp2, 2) irit.color(cpl2, irit.YELLOW) irit.SetResolution(20) irit.interact(irit.list(cbsp, cpl2, cpl)) irit.save("gpolyln1", irit.list(cbsp, cpl2, cpl))
irit.color(polylns, irit.MAGENTA) irit.interact(irit.list(b, polylns)) irit.free(polylns) be2 = irit.coerce(b, irit.E2) irit.color(b, irit.RED) p = irit.tseval(b, 1 / 3.0, 1 / 3.0, 1 / 3.0) n = irit.tsnormal(b, 1 / 3.0, 1 / 3.0, 1 / 3.0) nrml = (irit.coerce(p, irit.E3) + irit.coerce(irit.coerce(p, irit.POINT_TYPE) + n, irit.E3)) irit.save( "trisrf1", irit.list(b, be2, p, n, nrml, irit.fforder(b), irit.ffmsize(b), irit.ffctlpts(b), irit.pdomain(b), irit.tseval(b, 0, 0, 1), irit.tseval(b, 0, 1, 0), irit.tseval(b, 1, 0, 0), irit.tseval(b, 1 / 3.0, 1 / 3.0, 1 / 3.0), irit.tsnormal(b, 1 / 3.0, 1 / 3.0, 1 / 3.0))) irit.interact(irit.list(b, be2, nrml, p)) irit.free(b) irit.free(be2) c = irit.tsbezier( 4, irit.list( irit.ctlpt( irit.E3, 0, (-0.3 ), 0 ), \ irit.ctlpt( irit.E3, 0.2, (-0.5 ), (-0.2 ) ), \ irit.ctlpt( irit.E3, 0.6, (-0.3 ), 0.2 ), \ irit.ctlpt( irit.E3, 0.9, (-0.4 ), 0.1 ), \
irit.meval(irit.coerce(mv1, irit.KV_FLOAT), irit.list(1, 1, 3)), irit.meval(mv1, irit.list(1, 1, 3))) mv1 = irit.coerce( irit.tfromsrfs( irit.list(s1, s1 * irit.tx(0.25) * irit.ty(0.5) * irit.tz(0.8), s1 * irit.tz(2)), 3, irit.KV_FLOAT), irit.MULTIVAR_TYPE) printtest("coerce", irit.meval(irit.coerce(mv1, irit.KV_OPEN), irit.list(0, 0, 0)), irit.meval(mv1, irit.list(0, 0, 0))) printtest("coerce", irit.meval(irit.coerce(mv1, irit.KV_OPEN), irit.list(1, 1, 1)), irit.meval(mv1, irit.list(1, 1, 1))) printtest("pdomain", irit.pdomain(mc), irit.pdomain(c)) printtest("pdomain", irit.pdomain(ms), irit.pdomain(s)) printtest("pdomain", irit.pdomain(mt), irit.pdomain(t)) printtest("meval", irit.meval(mc, irit.list(0.3)), irit.ceval(c, 0.3)) printtest("meval", irit.meval(mc, irit.list(0.65)), irit.ceval(c, 0.65)) printtest("meval", irit.meval(ms, irit.list(0.3, 0.7)), irit.seval(s, 0.3, 0.7)) printtest("meval", irit.meval(ms, irit.list(0.65, 0.21)), irit.seval(s, 0.65, 0.21)) printtest("meval", irit.meval(ms3, irit.list(0.65, 0.21)), irit.seval(s3, 0.65, 0.21)) printtest("meval", irit.meval(mt, irit.list(0.123, 0.456, 0.789)), irit.teval(t, 0.123, 0.456, 0.789)) printtest("meval", irit.meval(mt, irit.list(0.321, 0.987, 0.654)),
dlevel = irit.iritstate("dumplevel", dlevel) irit.free(dlevel) tv1t = tv1 * irit.rotx(50) * irit.trans((1.5, (-1.5), 2)) irit.color(tv1t, irit.RED) tv2t = tv2 * irit.sc(0.75) * irit.trans(((-1.5), 1.5, (-2))) irit.color(tv2t, irit.GREEN) irit.interact(irit.list(tv1, tv1t)) irit.interact(irit.list(tv2, tv2t)) irit.save( "trivar2a", irit.list( irit.list( tv1, tv1t ), \ irit.list( tv2, tv2t ) * irit.tx( 3 ), \ irit.list( irit.fforder( tv1 ), irit.ffctlpts( tv1 ), irit.ffmsize( tv1 ), \ irit.pdomain( tv1 ), irit.fforder( tv2 ), irit.ffmsize( tv2 ), \ irit.ffkntvec( tv2 ), irit.ffctlpts( tv2 ), irit.pdomain( tv2t ) ), \ irit.list( irit.tvolume( tv1, 1 ), irit.tvolume( tv1t, 1 ), \ irit.tvolume( tv2, 1 ), irit.tvolume( tv2t, 1 ) ) ) ) irit.free(tv1t) irit.free(tv2t) # # Point inclusion # irit.tpinclude(tv2, (0, 0, 0), 20) # Prep. aux data. pts = irit.nil() x = -1
"trimsrf7", irit.list(offtsrf3a, tsrf3a, irit.seval(tsrf1a, 0.5, 0.5), irit.stangent(tsrf1a, irit.ROW, 0.5, 0.5, 1), irit.stangent(tsrf1a, irit.COL, 0.5, 0.5, 1), irit.snormal(tsrf1a, 0.5, 0.5), irit.seval(tsrf3a, 0.5, 0.5), irit.stangent(tsrf3a, irit.ROW, 0.5, 0.5, 1), irit.stangent(tsrf3a, irit.COL, 0.5, 0.5, 1), irit.snormal(tsrf3a, 0.5, 0.5))) irit.interact(irit.strimsrf(tsrf1a)) irit.interact(irit.ctrimsrf(tsrf1a, 1)) irit.interact(irit.ctrimsrf(tsrf3a, 0)) irit.save( "trimsrf8", irit.list(irit.pdomain(tsrf1a), irit.pdomain(tsrf3b), irit.strimsrf(tsrf1a), irit.ctrimsrf(tsrf1a, 1))) irit.free(s1) irit.free(s2) irit.save("trimsrf9", irit.list(tsrf2a, tsrf3b)) irit.printf("trim surfaces save/load test = %d\n", irit.list(irit.load("trimsrf9") == irit.list(tsrf2a, tsrf3b))) # ############################################################################ irit.free(offtsrf3a) irit.free(tsrf2bp) irit.free(tsrf2ap) irit.free(tsrf1a)
irit.free( crvsdm ) irit.free( vdir ) irit.free( crvse3 ) # ############################################################################ # # View point almost on the boundary from inside (art gallery guards) # res = irit.nil( ) i = 1 while ( i <= irit.SizeOf( crvs ) ): c = irit.nth( crvs, i ) co = irit.offset( c, irit.GenRealObject(-0.0001 ), 1e-006, 0 ) tmin = irit.FetchRealObject( irit.nth( irit.pdomain( co ), 1 ) ) tmax = irit.FetchRealObject( irit.nth( irit.pdomain( co ), 2 ) ) dt = 0.06 t = tmin while ( t <= tmax ): pt = irit.coerce( irit.ceval( co, t ), irit.POINT_TYPE ) irit.adwidth( pt, 3 ) irit.color( pt, irit.CYAN ) vc = irit.cvisible( c, irit.Fetch3TupleObject( pt * irit.tz( 1 ) ), 1e-005 ) irit.adwidth( vc, 3 ) irit.color( vc, irit.YELLOW ) if ( t == 0.12 or t == 0.36 or t == 0.6 or t == 0.84 ): irit.snoc( irit.list( pt, vc, c ) * irit.ty( i * 1.6 ) * irit.tx( t * 7 ), res ) irit.view( irit.list( pt, vc, c ), irit.ON ) t = t + dt i = i + 1