def printspeedchanges( str, crv ): dc = irit.cderive( crv ) speedsqr = irit.bbox( irit.symbdprod( dc, dc ) ) irit.printf( "%s [%f %f]\n", irit.list( str, asqrt( irit.FetchRealObject(irit.nth( speedsqr, 1 )) ), asqrt( irit.FetchRealObject(irit.nth( speedsqr, 2 )) ) ) )
def computeerror(crv, dist, ocrv): dst = irit.symbdiff(crv, ocrv) dstsqr = irit.symbdprod(dst, dst) ffmin = irit.max(irit.coord(irit.ffextreme(dstsqr, 1), 1), 0) ffmax = irit.max(irit.coord(irit.ffextreme(dstsqr, 0), 1), 0) irit.printf( "%1.0lf %lf", irit.list( irit.SizeOf(ocrv), irit.max(irit.abs(math.sqrt(ffmin) - dist), irit.abs(math.sqrt(ffmax) - dist))))
def computeerror(fname, crv, dist, ocrv): crv = irit.creparam(crv, 0, 1) ocrv = irit.creparam(ocrv, 0, 1) dst = irit.symbdiff(crv, ocrv) dstsqr = irit.symbdprod(dst, dst) ffmin = irit.max( irit.FetchRealObject(irit.coord(irit.ffextreme(dstsqr, 1), 1)), 0) ffmax = irit.max( irit.FetchRealObject(irit.coord(irit.ffextreme(dstsqr, 0), 1)), 0) irit.printf( "\n\t%s: min %lf, max %lf, max error %lf (ctlpts = %1.0lf)", irit.list( fname, math.sqrt(ffmin), math.sqrt(ffmax), irit.max(abs(math.sqrt(ffmin) - dist), abs(math.sqrt(ffmax) - dist)), irit.SizeOf(ocrv)))
irit.ctlpt( irit.E2, (-0.35 ), 1 ), \ irit.ctlpt( irit.E2, 0, 1 ) ), irit.list( irit.KV_OPEN ) ) * irit.sc( 0.7 ) c2 = irit.creparam(c1 * irit.rz(5) * irit.tx(0.65) * irit.ty(0.1), 0, 1) c1 = irit.creparam(c1 * irit.tx((-0.5)), 0, 1) irit.color(c1, irit.RED) irit.color(c2, irit.RED) mc1 = irit.mpromote(irit.coerce(c1, irit.MULTIVAR_TYPE), irit.list(1)) mc2 = irit.mpromote(irit.coerce(c2, irit.MULTIVAR_TYPE), irit.list(2, 1)) mn1 = irit.mpromote(irit.coerce(irit.cnrmlcrv(c1), irit.MULTIVAR_TYPE), irit.list(1)) mn2 = irit.mpromote(irit.coerce(irit.cnrmlcrv(c2), irit.MULTIVAR_TYPE), irit.list(2, 1)) constraints = irit.list(irit.symbdprod(irit.symbdiff(mc1, mc2), mn1), irit.symbdprod(irit.symbdiff(mc1, mc2), mn2)) irit.free(mc1) irit.free(mc2) irit.free(mn1) irit.free(mn2) z = irit.mzero(constraints, 0.001, 1e-010) irit.free(constraints) bitans = irit.nil() i = 1 while (i <= irit.SizeOf(z)): pt = irit.nth(z, i) irit.snoc( irit.ceval(c1, irit.FetchRealObject(irit.coord(pt, 1))) +
irit.save("nrml2srf", irit.list(irit.GetAxes(), s, ns, dus, dvs)) # # Compute two surfaces, one is an offset approximation to the surface and # the other is just a translation. Then compute the distance square scalar # surface between them and the original surface. With the data below both # Should have a distance square of 3 (if exact, the offset is obviously not). # s1 = s * irit.trans((1, (-1), 1)) irit.color(s1, irit.GREEN) s2 = irit.offset(s, irit.GenRealObject(math.sqrt(3)), 1, 0) irit.color(s2, irit.YELLOW) dlevel = irit.iritstate("dumplevel", irit.GenRealObject(255)) distsqr1 = irit.symbdprod(irit.symbdiff(s, s1), irit.symbdiff(s, s1)) distsqr2 = irit.symbdprod(irit.symbdiff(s, s2), irit.symbdiff(s, s2)) dlevel = irit.iritstate("dumplevel", dlevel) irit.save("dist1sqr", irit.list(distsqr1, distsqr2)) irit.free(s) irit.free(s1) irit.free(s2) irit.free(distsqr1) irit.free(distsqr2) irit.free(dus) irit.free(dvs) irit.free(ns)