-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hyperbola.py
34 lines (27 loc) · 833 Bytes
/
Hyperbola.py
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
from Conic import Conic
import math
import numpy as np
class Hyperbola(Conic):
def __init__(self, a, b, angle):
super().__init__(3*a, 3*b, angle)
self.a = a
self.b = b
def equate(self, x):
root = (self.b**2*((x**2/self.a**2) - 1))
if root >= 0:
return math.sqrt(root)
return None
def drawHyperbola(self):
self.plotCanvas()
def createXCoords(self):
# Create a linspace of XCoords
xCoords1 = np.arange(-5*self.a, -1*self.a, 0.005).tolist()
xCoords2 = np.arange(self.a, 5*self.a, 0.005).tolist()
xCoords = xCoords1 + xCoords2
return xCoords
print("Enter 'a' 'b' and 'angle' one by one")
a = int(input())
b = int(input())
angle = float(input())
hyperbola = Hyperbola(a, b, angle)
hyperbola.drawHyperbola()