def get_morton_curve(): chain_code = 'i','Ij','i' bases = ['ij'] * 4 return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def bauman(): proto = ((0, 0), (0, 1), (0, 2), (1, 2), (1, 1), (1, 0), (2, 0), (2, 1), (2, 2)) base_maps = [ BaseMap(perm=[1, 0], flip=[False, False]), BaseMap(perm=[1, 0], flip=[True, False]), BaseMap.id_map(dim=2), BaseMap(perm=[1, 0], flip=[False, True]), BaseMap(perm=[1, 0], flip=[True, True]), BaseMap(perm=[0, 1], flip=[False, True]), BaseMap(perm=[1, 0], flip=[False, False]), BaseMap(perm=[1, 0], flip=[True, False]), BaseMap.id_map(dim=2), ] bauman = FractalCurve(dim=2, div=3, proto=proto, base_maps=base_maps) bauman.estimate_ratio_vertex_brkline(ratio_l2, 3) #good.estimate_ratio(ratio, rel_tol=0.002, verbose=1) bauman = bauman.get_subdivision(1) pcurve = bauman.forget() pcurve = pcurve.changed(allow_time_rev=True) pcurve.estimate_ratio(ratio_l2, lower_bound=32.2, upper_bound=32.1, sat_pack=1000, find_model=True)
def get_serpentine_curve(): chain_code = 'jjiJJijj' bases = ['ij','Ji','ji','iJ','JI','iJ','ji','Ji','ij'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_tokarev_curve(): """3-D curve.""" chain_code = 'kjKikJK' bases = ['jki', 'kij', 'kij', 'iJK', 'iJK', 'KIj', 'KIj', 'JkI'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_haverkort_curve_2(): """3-D curve with time reversal.""" chain_code = 'kjKikJK' bases = ['KIJ1','KJI1','KjI0','Jki1','jki0','kjI1','kJI0','iKJ0'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_haverkort_curve_1(): """3-D curve with time reversal.""" chain_code = 'kjKikJK' bases = ['kji0','jik0','kIj1','iKJ0','IKJ1','KIj0','Kij1','Jki1'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_R_curve(): chain_code = 'jjiiJIJi' bases = ['ji','ji','ij','ij','ij','IJ','JI','JI','ij'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_coil_curve(): chain_code = 'jjiJJijj' bases = ['ji','Ji','ji','jI','JI','jI','ji','Ji','ji'] return FractalCurve( proto=chain2proto(chain_code), base_maps=[basis2base_map(b) for b in bases], )
def get_hilbert_curve(): """Example of fractal curve due to D.Hilbert.""" return FractalCurve( proto=[(0, 0), (0, 1), (1, 1), (1, 0)], base_maps=[ BaseMap([1, 0], [False, False]), # (x,y)->(y,x) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap([1, 0], [True, True]), # (x,y)->(1-y,1-x) ], )
def get_rev3_curve(): """Curve with time reversal at last cube.""" return FractalCurve( proto=[(0, 0), (0, 1), (1, 1), (1, 0)], base_maps=[ BaseMap([1, 0], [False, False]), # (x,y)->(y,x) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap([1, 0], [True, False], time_rev=True), # (x,y)->(1-y,x), t->1-t ], )
def get_peano_curve(): """Example of fractal curve due to G.Peano.""" id_map = BaseMap.id_map(2) x_map = BaseMap([0, 1], [True, False]) # (x,y)->(1-x,y) y_map = BaseMap([0, 1], [False, True]) # (x,y)->(x,1-y) xy_map = BaseMap([0, 1], [True, True]) # (x,y)->(1-x,1-y) return FractalCurve( proto=[(0, 0), (0, 1), (0, 2), (1, 2), (1, 1), (1, 0), (2, 0), (2, 1), (2, 2)], base_maps=[ id_map, x_map, id_map, y_map, xy_map, y_map, id_map, x_map, id_map, ], )
def get_haverkort_curve_A26(): """3-D curve with time reversal.""" proto = [(0,0,0), (0,0,1), (0,1,1), (0,1,0), (1,1,0), (1,1,1), (1,0,1), (1,0,0)] base_maps = [ BaseMap([2, 1, 0], [False, False, False]), BaseMap([2, 0, 1], [False, False, False]), BaseMap([2, 0, 1], [False, True, False], time_rev=True), BaseMap([0, 2, 1], [False, True, True]), BaseMap([0, 2, 1], [True, True, True], time_rev=True), BaseMap([2, 0, 1], [True, True, False]), BaseMap([2, 0, 1], [True, False, False], time_rev=True), BaseMap([1, 2, 0], [True, False, False], time_rev=True), ] return FractalCurve( proto=proto, base_maps=base_maps, )
def get_scepin_bauman_curve(): proto = ( (0, 0), (0, 1), (0, 2), (1, 2), (1, 1), (1, 0), (2, 0), (2, 1), (2, 2), ) base_maps = [ BaseMap.id_map(dim=2), BaseMap([1,0],[True,False]), # rot(90) BaseMap([1,0],[False,False]), # (x,y)->(y,x) BaseMap([0,1],[False,True]), # (x,y)->(x,1-y) BaseMap([1,0],[True,True]), # (x,y)->(1-y,1-x) BaseMap([1,0],[False,True]), # rot(-90) BaseMap.id_map(dim=2), BaseMap(perm=[1,0],flip=[True,False]), # rot(90) BaseMap(perm=[1,0],flip=[False,False]), # (x,y)->(y,x) ] return FractalCurve(dim=2, div=3, proto=proto, base_maps=base_maps)
def get_peano5_curve(): id_map = BaseMap.id_map(2) x_map = BaseMap([0, 1], [True, False]) # (x,y)->(1-x,y) y_map = BaseMap([0, 1], [False, True]) # (x,y)->(x,1-y) xy_map = BaseMap([0, 1], [True, True]) # (x,y)->(1-x,1-y) return FractalCurve( dim=2, div=5, proto=[ (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (1, 3), (1, 2), (1, 1), (1, 0), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, 4), (3, 3), (3, 2), (3, 1), (3, 0), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), ], base_maps=[ id_map, x_map, id_map, x_map, id_map, y_map, xy_map, y_map, xy_map, y_map, id_map, x_map, id_map, x_map, id_map, y_map, xy_map, y_map, xy_map, y_map, id_map, x_map, id_map, x_map, id_map, ], )
def generate_curves_for_brkline(self, brkline): global_entrance = (0, ) * self.dim global_exit = self.exit bms_variants = [] proto = [] for cube, entrance, exit in brkline: constr = { global_entrance: entrance, global_exit: exit, } bms_for_cube = base_map.gen_constraint_base_maps(self.dim, constr) if self.oriented: bms_for_cube = (bm for bm in bms_for_cube if bm.is_oriented()) bms_variants.append(bms_for_cube) proto.append(cube) for bms in itertools.product(*bms_variants): curve = FractalCurve(dim=self.dim, div=self.div, proto=proto, base_maps=bms) yield curve
def get_discontinuous_curve(): return FractalCurve( proto=[(1, 1), (0, 1), (0, 0), (1, 0), (2, 0), (2, 1), (2, 2), (1, 2), (0, 2)], base_maps=[BaseMap.id_map(2)] * 9, )
def pristalno(): proto = [ (0, 0), (1, 0), (1, 1), (0, 1), (0, 2), (1, 2), (1, 3), (0, 3), (0, 4), (1, 4), (2, 4), (2, 3), (3, 3), (3, 4), (4, 4), (4, 3), (4, 2), (3, 2), (2, 2), (2, 1), (2, 0), (3, 0), (3, 1), (4, 1), (4, 0), ] bmstrs = [ '(x,y)->(x,y)', '(x,y)->(y,1-x),t->1-t', '(x,y)->(y,1-x),t->1-t', '(x,y)->(1-x,1-y)', '(x,y)->(x,y)', '(x,y)->(y,1-x),t->1-t', '(x,y)->(y,1-x),t->1-t', '(x,y)->(1-x,1-y)', '(x,y)->(x,y)', '(x,y)->(x,y)', '(x,y)->(x,y)', '(x,y)->(1-y,x),t->1-t', '(x,y)->(y,1-x),t->1-t', '(x,y)->(x,y)', '(x,y)->(x,y)', '(x,y)->(1-y,x),t->1-t', '(x,y)->(1-x,1-y)', '(x,y)->(1-x,1-y)', '(x,y)->(1-y,x),t->1-t', '(x,y)->(1-y,x),t->1-t', '(x,y)->(1-y,x),t->1-t', '(x,y)->(y,1-x),t->1-t', '(x,y)->(x,y)', '(x,y)->(x,y)', '(x,y)->(1-y,x),t->1-t', ] base_maps = [bmstr2base_map(x) for x in bmstrs] curve = FractalCurve(dim=2, div=5, proto=proto, base_maps=base_maps) curve.check() print(curve.get_junctions()) print('entr:', curve.get_entrance()) print('exit:', curve.get_exit()) curve.estimate_ratio_new(ratio_l2, rel_tol=0.001, max_iter=1000) pcurve = curve.forget() pcurve.allow_time_rev = True result = pcurve.estimate_ratio(ratio_l2, lower_bound=31.2, upper_bound=31.3, find_model=True) if result: print('found:', result.proto, result.base_maps) else: print('NOT FOUND')