Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1.         ratio   = radius / (wreck1.radius - radius)
  2.         shiftx  = (x - wreck1.x) * ratio
  3.         shifty  = (y - wreck1.y) * ratio
  4.         slope   = (wreck2.x - wreck1.x) / (wreck1.y - wreck2.y)
  5.         Yfunct  = lambda fx: slope * (fx - x) + y
  6.         place   = y - wreck1.y - slope * x
  7.        
  8.         A = 1 + slope ** 2
  9.         B = 2 * slope * place - 2 * wreck1.x
  10.         C = slope ** 2 + wreck1.x ** 2 - wreck1.radius ** 2
  11.        
  12.         p3x =  ( (- B) + (B ** 2 - 4 * A * C) ** (1/2) ) / (2 * A)
  13.         p4x =  ( (- B) - (B ** 2 - 4 * A * C) ** (1/2) ) / (2 * A)
  14.        
  15.         self.p1 = (x - shiftx, y - shifty)
  16.         self.p2 = (x + shiftx, y + shifty)
  17.         self.p3 = (p3x, Yfunct(p3x))
  18.         self.p4 = (p4x, Yfunct(p4x))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement