-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhilbert_curve.py
More file actions
executable file
·69 lines (40 loc) · 1.49 KB
/
Copy pathhilbert_curve.py
File metadata and controls
executable file
·69 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 24 18:14:46 2022
@author: tandeitnik
"""
import numpy as np
import matplotlib.pyplot as plt
seed_x = np.array([1,1,3,3])
seed_y = np.array([1,3,3,1])
steps = 4
for k in range(steps):
#rotating 90
left_inf_x = np.copy(seed_y)
left_inf_y = np.copy(seed_x)
#plt.plot(left_inf_x,left_inf_y)
#two copies deslocated
left_sup_x = np.copy(seed_x)
left_sup_y = np.copy(seed_y) + 4*2**k
#plt.plot(left_sup_x,left_sup_y)
right_sup_x = np.copy(seed_x) + 4*2**k
right_sup_y = np.copy(seed_y) + 4*2**k
#plt.plot(right_sup_x,right_sup_y)
# rotated flipped deslocated
right_inf_x = np.flip(np.copy(seed_y))
right_inf_y = np.flip(np.copy(seed_x))
centro = 2*2**k
for j in range(len(right_inf_x)):
if right_inf_x[j] < centro:
right_inf_x[j] += 2*(centro-right_inf_x[j])
elif right_inf_x[j] > centro:
right_inf_x[j] -= 2*(right_inf_x[j]-centro)
right_inf_x = right_inf_x + 4*2**k
#plt.plot(right_inf_x,right_inf_y)
#piecing it all together
seed_x = np.array(list(left_inf_x) + list(left_sup_x) + list(right_sup_x)+ list(right_inf_x))
seed_y = np.array(list(left_inf_y) + list(left_sup_y) + list(right_sup_y)+ list(right_inf_y))
#plt.plot(seed_x,seed_y)
plt.plot(seed_x,seed_y)
plt.axis("off")