I have the xy-coordinates of two shots. In addition, I have the distance, d, of each shot to the hole. The goal is to find out the xy-coordinate of the hole (xh
, yh
).
# known
x1 = 11518.096
y1 = 12693.551
d1 = 3693
x2 = 11227.928
y2 = 12537.854
d2 = 342
Consequently, we have the following equations:
We then arrange them into the following form:
I want to write the above in Python
import numpy as np
from scipy.optimize import newton
# the function whose zero is wanted
def f(x: float, y: float, d: float) -> float:
return (x - xh) ** 2 + (y - yh) ** 2 - d ** 2
guess = newton(f, np.array([x1, y1]), args=(x1, y1, d1))
According to this answer I need to args
to provide the constant parameters. In addition, I am using x1
/y1
or x2
/y2
as initial guesses
What's the next step to use both shots? How should newton
be called?
# unknown
xh = 11255.902
yh = 12532.519