def get_peano5_curve(): id_map = BaseMap.id_map(2) x_map = BaseMap([(0, True), (1, False)]) # (x,y)->(1-x,y) y_map = BaseMap([(0, False), (1, True)]) # (x,y)->(x,1-y) xy_map = BaseMap([(0, True), (1, True)]) # (x,y)->(1-x,1-y) 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, ] return Curve(dim=2, div=5, patterns=[(proto, base_maps)])
def get_scepin_bauman_curve(): """ Minimal 3*3 Peano Curve by E.V. Shchepin and K.E. Bauman. Proceedings of the Steklov Institute of Mathematics, 2008, Vol. 263, pp. 236--256. """ proto = ( # as in peano curve (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.parse('jI'), BaseMap.parse('ji'), BaseMap.parse('iJ'), BaseMap.parse('JI'), BaseMap.parse('Ji'), BaseMap.id_map(dim=2), BaseMap.parse('jI'), BaseMap.parse('ji'), ] return Curve(dim=2, div=3, patterns=[(proto, base_maps)])
def get_beta_Omega_Curve(): chain_code_list = ['jiJ', 'jiJ'] bases_list = [['1iJ', '1Ji', '1ji~', '1IJ~'], ['1iJ', '1Ji', '1ji~', '0jI']] return Curve(dim=2, div=2, patterns=get_patterns(chain_code_list, bases_list))
def get_17_curve(): """ 3D bifractal facet-gated curve with l2-ratio <17 """ p0 = ('jikIJiK', '1KIJ~,0KIj,1kji,0Jki~,1JkI,0kIJ,1KJi,1JiK') p1 = ('jkJijKJ', '1KIJ~,0ijK~,0Ikj~,0KJI~,0kiJ~,0Ijk~,0IjK,1iKJ') return Curve.parse([p0, p1])
def get_rev_curves(): chain = 'jiJ' bases_list = [ 'ji,Ij~,ij,JI', # time rev at the middle 'Ji~,ij,ij,JI', # time rev at first cube 'ji,ij,ij,jI~', # time rev at last cube ] return [Curve.parse([(chain, b)]) for b in bases_list]
def get_rev_curves(): chain = 'jiJ' bases_list = [ ['ji','Ij~','ij','JI'], # time rev at the middle ['Ji~','ij','ij','JI'], # time rev at first cube ['ji','ij','ij','jI~'], # time rev at last cube ] return [Curve.parse([(chain, b)]) for b in bases_list]
def get_hilbert_curve(): """ Example of fractal curve due to D.Hilbert. This curve has minimal known L_1 ratio (9). """ pattern = ('jiJ', 'ji,ij,ij,JI') return Curve.parse([pattern])
def get_scepin_bauman_curve(): """ Minimal 3*3 Peano Curve by E.V. Shchepin and K.E. Bauman. Proceedings of the Steklov Institute of Mathematics, 2008, Vol. 263, pp. 236--256. """ pattern = ('jjiJJijj', 'ij,jI,ji,iJ,JI,Ji,ij,jI,ji') return Curve.parse([pattern])
def get_hilbert_curve(): """ Example of fractal curve due to D.Hilbert. This curve has minimal known L_1 ratio (9). """ pattern = ('jiJ', ['ji', 'ij', 'ij', 'JI']) # chain code + bases return Curve.parse([pattern])
def get_tokarev_curve(): """ 3D monofractal curve defined by Tokarev. Definition is taken from Haverkort's inventory, Curve A26.0000 0000.0000 0000 (page 9, Fig.5(b)) """ p0 = ('jkJijKJ', ['jki', 'kij', 'kij', 'iJK', 'iJK', 'KIj', 'KIj', 'JkI']) return Curve.parse([p0])
def get_luna_curve(): chain_code = ['kjKikJK', 'kiKjIki'] bases = [['1ijk', '0KJi', '1KiJ', '1jKI', '1jik', '1IKj', '0kJI', '1kJI'], ['1jik', '0JKi', '1iKJ', '0KiJ', '1KjI', '1JIk', '0ikj', '1ikj']] return Curve( dim=3, div=2, patterns=get_patterns(chain_code, bases), )
def get_neptunus_curve(): chain_code = ['kjKikJK', 'kiKjIki'] bases = [['0kji', '1kji', '1KiJ', '1jKI', '1ikj', '1KJi', '0kJI', '1jKI'], ['0jki', '1jki', '1iKJ', '0KiJ', '1JiK', '1IKj', '0ikj', '1ijk']] return Curve( dim=3, div=2, patterns=get_patterns(chain_code, bases), )
def get_morton_curve(): chain_code = 'i', 'Ij', 'i' bases = ['ij'] * 4 return Curve( dim=2, div=2, patterns=[(chain2proto(chain_code), [basis2base_map(b) for b in bases])], )
def get_discontinuous_curve(): proto = [(1, 1), (0, 1), (0, 0), (1, 0), (2, 0), (2, 1), (2, 2), (1, 2), (0, 2)] return Curve( dim=2, div=2, patterns=[ (proto, [BaseMap.id_map(2)] * 9), ], )
def get_R_curve(): chain_code = 'jjiiJIJi' bases = ['ji', 'ji', 'ij', 'ij', 'ij', 'IJ', 'JI', 'JI', 'ij'] return Curve( dim=2, div=3, patterns=[ (chain2proto(chain_code), [basis2base_map(b) for b in bases]), ], )
def get_hilbert_curve(): """Example of fractal curve due to D.Hilbert.""" proto = [(0, 0), (0, 1), (1, 1), (1, 0)] base_maps = [ BaseMap.parse('(x,y)->(y,x)'), BaseMap.id_map(2), BaseMap.id_map(2), BaseMap.parse('(x,y)->(1-y,1-x)'), ] return Curve(dim=2, div=2, patterns=[(proto, base_maps)])
def get_serpentine_curve(): chain_code = 'jjiJJijj' bases = ['ij', 'Ji', 'ji', 'iJ', 'JI', 'iJ', 'ji', 'Ji', 'ij'] return Curve( dim=2, div=3, patterns=[ (chain2proto(chain_code), [basis2base_map(b) for b in bases]), ], )
def get_luna_curve(): """ 3D bifractal Luna curve Inventory ref, p.16 gates: (0,0,0)->(1,0,0), (0,0,0)->(1,1,1) """ p0 = ('jkJijKJ', '1kji,0jIK,1JIk,1iKJ,1ijk,1jKI,0JiK,1KiJ') p1 = ('jkJiKjk', '1kji,0jIK,1JIk,1iKJ,0ijk,1KjI,0kij,1jik') return Curve.parse([p0, p1])
def get_ARW_Curve(): """ AR^2W^2 tetrafractal curve. See reference to Haverkort & Walderveen in get_beta_omega_curve doc """ r_pattern = ('i(Ij)i', ['3ij', '1Ji~', '2jI', '1iJ']) # pnum=0 f_pattern = ('jiJ', ['3ji', '2Ij~', '1ij', '1JI']) # pnum=1 p_pattern = ('jiJ', ['0ji', '1jI', '0Ji', '1JI']) # pnum=2 g_pattern = ('jiJ', ['0ij', '2jI', '0Ji', '3jI~']) # pnum=3 return Curve.parse([r_pattern, f_pattern, p_pattern, g_pattern])
def get_tokarev_curve(): """3-D curve.""" chain_code = 'kjKikJK' bases = ['jki', 'kij', 'kij', 'iJK', 'iJK', 'KIj', 'KIj', 'JkI'] return Curve( dim=3, div=2, patterns=[ (chain2proto(chain_code), [basis2base_map(b) for b in bases]), ], )
def get_hilbert_bicurve(): """Fake bifractal curve, actually it is Hilber curve.""" curve = get_hilbert_curve() p1 = (curve.proto, [ Spec(sp.base_map, pnum=cnt % 2) for cnt, sp in enumerate(curve.specs) ]) p2 = (curve.proto, [ Spec(sp.base_map, pnum=(cnt + 1) % 2) for cnt, sp in enumerate(curve.specs) ]) return Curve(dim=2, div=2, patterns=[p1, p2])
def get_ARW_Curve(): """ AR^2W^2 tetrafractal curve. See reference to Haverkort & Walderveen in get_beta_omega_curve doc """ r_pattern = ('i(Ij)i', '3ij,1Ji~,2jI,1iJ') # pnum=0 f_pattern = ('jiJ', '3ji,2Ij~,1ij,1JI') # pnum=1 p_pattern = ('jiJ', '0ji,1jI,0Ji,1JI') # pnum=2 g_pattern = ('jiJ', '0ij,2jI,0Ji,3jI~') # pnum=3 return Curve.parse([r_pattern, f_pattern, p_pattern, g_pattern])
def get_haverkort_curve_2(): """3-D curve with time reversal.""" chain_code = 'kjKikJK' bases = ['KIJ~', 'KJI~', 'KjI', 'Jki~', 'jki', 'kjI~', 'kJI', 'iKJ'] return Curve( dim=3, div=2, patterns=[ (chain2proto(chain_code), [basis2base_map(b) for b in bases]), ], )
def get_rev3_curve(): """Curve with time reversal at last cube.""" proto = [(0, 0), (0, 1), (1, 1), (1, 0)] base_maps = [ BaseMap([(1, False), (0, False)]), # (x,y)->(y,x) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap.id_map(2), # (x,y)->(x,y) BaseMap([(1, True), (0, False)], time_rev=True), # (x,y)->(1-y,x), t->1-t ] return Curve(dim=2, div=2, patterns=[(proto, base_maps)])
def get_haverkort_curve_1(): """3-D curve with time reversal.""" chain_code = 'kjKikJK' bases = ['kji', 'jik', 'kIj~', 'iKJ', 'IKJ~', 'KIj', 'Kij~', 'Jki~'] return Curve( dim=3, div=2, patterns=[ (chain2proto(chain_code), [basis2base_map(b) for b in bases]), ], )
def get_luna_curve(): """ 3D bifractal Luna curve Inventory ref, p.16 gates: (0,0,0)->(1,0,0), (0,0,0)->(1,1,1) """ p0 = ('jkJijKJ', ['1kji', '0jIK', '1JIk', '1iKJ', '1ijk', '1jKI', '0JiK', '1KiJ']) p1 = ('jkJiKjk', ['1kji', '0jIK', '1JIk', '1iKJ', '0ijk', '1KjI', '0kij', '1jik']) return Curve.parse([p0, p1])
def get_neptunus_curve(): """ 3D bifractal Neptunus curve, best in linf (9.45) "An inventory of three-dimensional Hilbert space-filling curves", Herman Haverkort https://arxiv.org/abs/1109.2323 p.16 Properties: ratio: linf=9.45, best in class of poly-Hilbert curves gates: (0,0,0)->(1,0,0), (0,0,0)->(1,1,1) """ p0 = ('jkJijKJ', '1ijk,0jIK,1kJI,1JiK,1ijk,1jKI,1KJi,0JIk') p1 = ('jkJiKjk', '1ijk,0jIK,1kJI,1JiK,0ijk,1KjI,1jki,0kIJ') return Curve.parse([p0, p1])
def get_haverkort_curve_a26(): """ 3D Haverkort A26 curve, best monofractal in linf. Monofractal curve with time reversal. "An inventory of three-dimensional Hilbert space-filling curves", Herman Haverkort https://arxiv.org/abs/1109.2323 Curve A26.0010 1011.1011 0011, see p.10, p.15, p.18 Properties: ratio: linf=12.4 gate: (0,0,0)->(1,0,0) """ pattern = ('jkJijKJ', 'Jki~,Kij~,kij,IKJ~,iKJ,kIj~,KIj,JIk') return Curve.parse([pattern])
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, False), (1, False), (0, False)]), BaseMap([(2, False), (0, False), (1, False)]), BaseMap([(2, False), (0, True), (1, False)], time_rev=True), BaseMap([(0, False), (2, True), (1, True)]), BaseMap([(0, True), (2, True), (1, True)], time_rev=True), BaseMap([(2, True), (0, True), (1, False)]), BaseMap([(2, True), (0, False), (1, False)], time_rev=True), BaseMap([(1, True), (2, False), (0, False)], time_rev=True), ] return Curve(dim=3, div=2, patterns=[(proto, base_maps)])
def get_haverkort_curve_f(): """ 3D Haverkort F curve, best known monofractal in l2 Monofractal curve with time reversal, "An inventory of three-dimensional Hilbert space-filling curves", Herman Haverkort https://arxiv.org/abs/1109.2323 Curve F, see p.13, p.15, p.18 Properties: ratio: l1=89.8, l2=18.6 (best known!) gate: (0,1/3,1/3)->(2/3,1/3,0) """ pattern = ('jkJijKJ', 'iKJ,jIK,jIk~,JkI,Jki~,jik,jiK~,kiJ~') return Curve.parse([pattern])