Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_glob_loc(A,B):
- a=A.x
- b=A.y
- c=B.x
- d=B.y
- r_1=A.dist
- r_2=B.dist
- #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
- gradient_of_A_B=(d-b)/(c-a)
- inv_gradient_of_A_B=(-1)/gradient_of_A_B
- midpoint_A_B=coordinate((a+c)/2,(b+d)/2)
- #identify the C constant
- c=midpoint_A_B.y-(inv_gradient_of_A_B*midpoint_A_B.x)
- #plug into the rearranged circle formula
- #simplification variable:
- simple=r_1**2 - ((inv_gradient_of_A_B*midpoint_A_B.x)+c-b)**2
- x_pos=a+math.sqrt(simple)
- x_neg=a-math.sqrt(simple)
- y_pos=(inv_gradient_of_A_B*x_pos)+c
- y_neg=(inv_gradient_of_A_B*x_neg)+c
- pos=coordinate(x_pos,y_pos)
- neg=coordinate(x_neg,y_neg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement