File size: 3,248 Bytes
b721bd3
 
 
 
 
 
 
 
 
 
 
 
c1ab7e8
b721bd3
 
c1ab7e8
b721bd3
 
 
b8c9155
b721bd3
 
 
 
b8c9155
 
 
 
b721bd3
 
 
 
c1ab7e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import numpy as np
import matplotlib.pyplot as plt

def getSquareY(x):
    if x==-1 or x == 1:
        return 0
    else:
        return 1

getSquareYVectorised = np.vectorize(getSquareY)

def getCircle(x):
    return np.sqrt(1 - np.square(x))

def transform(x,y,t):
    points = np.array([x, y])
    result = t @ points
    return result[0,:], result[1,:]

def plotGridLines(xlim,ylim,t,color,label,linewidth):
    for i in range(xlim[0]-20,xlim[1]+21):
        x = [i,i]
        y = [ylim[0]-20,ylim[1]+20]
        x,y = transform(x,y,t)
        if i == xlim[0]-20:
            plt.plot(x,y, color=color,linestyle='dashed',linewidth=linewidth,label=label)
        else:
            plt.plot(x,y, color=color,linestyle='dashed',linewidth=linewidth)
    for i in range(ylim[0]-20,ylim[1]+21):
        y = [i,i]
        x = [xlim[0]-20,xlim[1]+20]
        x,y = transform(x,y,t)
        plt.plot(x,y, color=color,linestyle='dashed',linewidth=linewidth)

def discriminant(t):
    return t[0,0]**2 - 2*t[1,1]*t[0,0] + t[1,1]**2 + 4*t[0,1]*t[1,0]

def getBatman(s=2):
    X = []
    Y = []
    
    # lower
    x = np.linspace(-4, 4, 1600)
    y = np.zeros((0))
    for px in x:
        y = np.append(y,abs(px/2)- 0.09137*px**2 + np.sqrt(1-(abs(abs(px)-2)-1)**2) -3)
    X.append(x/s)
    Y.append(y/s)
    
    # lower left
    x = np.linspace(-7., -4, 300)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, -3*np.sqrt(-(px/7)**2+1))
    X.append(x/s)
    Y.append(y/s)
    
    # lower right
    x = np.linspace(4, 7, 300)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, -3*np.sqrt(-(px/7)**2+1))
    X.append(x/s)
    Y.append(y/s)
    
    # top left
    x = np.linspace(-7, -2.95, 300)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 3*np.sqrt(-(px/7)**2+1))
    X.append(x/s)
    Y.append(y/s)
    
    # top right
    x = np.linspace(2.95, 7, 300)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 3*np.sqrt(-(px/7)**2+1))
    X.append(x/s)
    Y.append(y/s)
    
    # left ear left
    x = np.linspace(-1, -.77, 2)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 9-8*abs(px))
    X.append(x/s)
    Y.append(y/s)
    
    # right ear right
    x = np.linspace(.77, 1, 2)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 9-8*abs(px))
    X.append(x/s)
    Y.append(y/s)
    
    # mid
    x = np.linspace(-.43, .43, 100)
    y = np.zeros((0))
    for px in x:
        y = np.append(y,2)
    X.append(x/s)
    Y.append(y/s)
        
    x = np.linspace(-2.91, -1, 100)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 1.5 - .5*abs(px) - 1.89736*(np.sqrt(3-px**2+2*abs(px))-2) )
    X.append(x/s)
    Y.append(y/s)
    
    x = np.linspace(1, 2.91, 100)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 1.5 - .5*abs(px) - 1.89736*(np.sqrt(3-px**2+2*abs(px))-2) )
    X.append(x/s)
    Y.append(y/s)
    
    x = np.linspace(-.7,-.43, 10)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 3*abs(px)+.75)
    X.append(x/s)
    Y.append(y/s)
    
    x = np.linspace(.43, .7, 10)
    y = np.zeros((0))
    for px in x:
        y = np.append(y, 3*abs(px)+.75)
    X.append(x/s)
    Y.append(y/s)
    
    return X, Y