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_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_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 test_apply_base_map_unit(self): """Test that the application of a sequence of base_maps with unit product does not change the curve.""" rot_90 = BaseMap([(1,True), (0,False)]) # поворот на 90 градусов rot_90_t = BaseMap.parse('jI~') bms_list = [ [rot_90] * 3, [rot_90_t] * 3, [ BaseMap([(1,False), (0,False)], time_rev=True), BaseMap([(0,True), (1,False)]), ], [ BaseMap([(0,True),(2,False),(1,True)], time_rev=True), BaseMap([(1,False),(0,True),(2,True)], time_rev=True), ], ] for bms in bms_list: # will make bms[0] * bms[1] * ... * bms[-1] * last_map = id <=> last_map = bms[-1]^{-1} * ... * bms[0]^{-1} last_map = BaseMap.id_map(dim=bms[0].dim) for bm in bms: last_map = bm**(-1) * last_map for curve in self.curves: if curve.dim != bms[0].dim: continue orig = curve current = curve for bm in reversed(bms + [last_map]): current = bm * current self.assertEqual(orig.proto, current.proto) self.assertEqual(orig.specs, current.specs)
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_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_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, True), (0, False)]), # rot(90) BaseMap.parse('(x,y)->(y,x)'), BaseMap.parse('(x,y)->(x,1-y)'), BaseMap.parse('(x,y)->(1-y,1-x)'), BaseMap([(1, False), (0, True)]), # rot(-90) BaseMap.id_map(dim=2), BaseMap([(1, True), (0, False)]), # rot(90) BaseMap([(1, False), (0, False)]), # (x,y)->(y,x) ] return Curve(dim=2, div=3, patterns=[(proto, base_maps)])
def get_rev_curve(): """Curve with time reversal at some middle cube.""" return Curve( dim=2, div=2, patterns=[ ( [(0, 0), (0, 1), (1, 1), (1, 0)], [ BaseMap([(1, False), (0, False)]), # (x,y)->(y,x) BaseMap([(0, True), (1, False)], time_rev=True), # (x,y)->(1-x,y), t->1-t BaseMap.id_map(2), # (x,y)->(x,y) BaseMap([(1, True), (0, True)]), # (x,y)->(1-y,1-x) ], ), ], )
def get_peano_curve(): """Example of fractal curve due to G.Peano.""" 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), (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, ] return Curve(dim=2, div=3, patterns=[(proto, base_maps)])
def test_inv(self): for bm in self.base_maps: self.assertEqual(bm * ~bm, BaseMap.id_map(dim=bm.dim)) self.assertEqual(~bm * bm, BaseMap.id_map(dim=bm.dim))
def get_peano5_curve(): """5-div analog of original Peano curve.""" id_map = BaseMap.id_map(2) x_map = BaseMap.parse('Ij') y_map = BaseMap.parse('iJ') xy_map = BaseMap.parse('IJ') 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)])