Example #1
0
def measure_bz(curve, s0, s1, bz):
	bz_arclen = tocubic.bz_arclength_rk4(bz)
	if bz_arclen == 0: return 1e9
	arclen_scale = (s1 - s0) / bz_arclen
	def th_fn(s):
		return curve.th(s0 + arclen_scale * s, s == 0)
	return tocubic.measure_bz_rk4(bz, bz_arclen, th_fn)
Example #2
0
def measure_bz(curve, s0, s1, bz):
	bz_arclen = tocubic.bz_arclength_rk4(bz)
	if bz_arclen == 0: return 1e9
	arclen_scale = (s1 - s0) / bz_arclen
	def th_fn(s):
		return curve.th(s0 + arclen_scale * s, s == 0)
	return tocubic.measure_bz_rk4(bz, bz_arclen, th_fn)
Example #3
0
def measure_bz_cloth(seg, bz, n = 100):
    bz_arclen = tocubic.bz_arclength_rk4(bz)
    arclen_ratio = seg.arclen / bz_arclen
    dbz = tocubic.bz_deriv(bz)
    
    def measure_derivs(x, ys):
        dx, dy = tocubic.bz_eval(dbz, x)
        ds = hypot(dx, dy)
        s = ys[0] * arclen_ratio
        dscore = ds * (tocubic.mod_2pi(atan2(dy, dx) - seg.th(s)) ** 2)
        #print s, atan2(dy, dx),  seg.th(s)
        return [ds, dscore]
    dt = 1./n
    t = 0
    ys = [0, 0]
    for i in range(n):
        dydx = measure_derivs(t, ys)
        tocubic.rk4(ys, dydx, t, dt, measure_derivs)
        t += dt
    return ys[1]
Example #4
0
def measure_bz_cloth(seg, bz, n=100):
    bz_arclen = tocubic.bz_arclength_rk4(bz)
    arclen_ratio = seg.arclen / bz_arclen
    dbz = tocubic.bz_deriv(bz)

    def measure_derivs(x, ys):
        dx, dy = tocubic.bz_eval(dbz, x)
        ds = hypot(dx, dy)
        s = ys[0] * arclen_ratio
        dscore = ds * (tocubic.mod_2pi(atan2(dy, dx) - seg.th(s))**2)
        #print s, atan2(dy, dx),  seg.th(s)
        return [ds, dscore]

    dt = 1. / n
    t = 0
    ys = [0, 0]
    for i in range(n):
        dydx = measure_derivs(t, ys)
        tocubic.rk4(ys, dydx, t, dt, measure_derivs)
        t += dt
    return ys[1]