TimNekkYT

Untitled

Mar 3rd, 2022
1,463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1.     def asymptote(self, x='x', y='y', equation=False, _slope=None):
  2.         x0 = self.center.x
  3.         y0 = self.center.y
  4.         a = self.hradius
  5.         b = self.vradius
  6.         c = self.focus_distance
  7.         x = self.directrix()[0]
  8.  
  9.         if _slope:
  10.             k1 = (b + a * tan(_slope)) / (a - b * tan(_slope))
  11.             k2 = (-b + a * tan(_slope)) / (a + b * tan(_slope))
  12.             eq1 = y0 - k1 * (x - x0)
  13.             eq2 = y0 + k2 * (x - x0)
  14.         else:
  15.             eq1 = y0 + (b / a) * (x - x0)
  16.             eq2 = y0 - (b / a) * (x - x0)
  17.  
  18.         if equation:
  19.             x = Symbol('x')
  20.             y = Symbol('x')
  21.             return Eq(y, eq1), Eq(y, eq2)
  22.         else:
  23.             return eq1, eq2
  24.  
  25.     def directrix(self, _x='x', _y='y', equation=False, _slope=None):
  26.         x0 = self.center.x
  27.         y0 = self.center.y
  28.         a = self.hradius
  29.         c = self.focus_distance
  30.  
  31.         if _slope:
  32.             x = self.directrix()[0]
  33.             eq1 = y0 - cot(_slope) * (x - x0) + (a ** 2 / c) * sqrt(1 + cot(_slope))
  34.             eq2 = y0 - cot(_slope) * (x - x0) - (a ** 2 / c) * sqrt(1 + cot(_slope))
  35.         else:
  36.             eq1 = x0 + a ** 2 / c
  37.             eq2 = x0 - a ** 2 / c
  38.  
  39.         if equation:
  40.             x = Symbol('x')
  41.             y = Symbol('x')
  42.             return (Eq(y, eq1), Eq(y, eq2)) if _slope else (Eq(x, eq1), Eq(x, eq2))
  43.         else:
  44.             return eq1, eq2
Advertisement
Add Comment
Please, Sign In to add comment