Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. def get_glob_loc(A,B):
  2.     a=A.x
  3.     b=A.y
  4.     c=B.x
  5.     d=B.y
  6.     r_1=A.dist
  7.     r_2=B.dist
  8.     #first need to create the line. the one going through the midpoint and the points of intersection, perpendicular to the line going through A and B
  9.     gradient_of_A_B=(d-b)/(c-a)
  10.     inv_gradient_of_A_B=(-1)/gradient_of_A_B
  11.  
  12.     midpoint_A_B=coordinate((a+c)/2,(b+d)/2)
  13.     #identify the C constant
  14.     c=midpoint_A_B.y-(inv_gradient_of_A_B*midpoint_A_B.x)
  15.  
  16.     #plug into the rearranged circle formula
  17.     #simplification variable:
  18.     simple=r_1**2 - ((inv_gradient_of_A_B*midpoint_A_B.x)+c-b)**2
  19.     x_pos=a+math.sqrt(simple)
  20.     x_neg=a-math.sqrt(simple)
  21.  
  22.     y_pos=(inv_gradient_of_A_B*x_pos)+c
  23.     y_neg=(inv_gradient_of_A_B*x_neg)+c
  24.  
  25.     pos=coordinate(x_pos,y_pos)
  26.     neg=coordinate(x_neg,y_neg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement