我正在尝试添加另一个接收器,或者换句话说,增加第4点。 我怎么能修改此功能,以发现红色X相对于四个蓝色点(具有已知的X,Y位置)的图(有X,Y形式和未知坐标)而不仅仅是3个任何想法(见阴谋链接下面) ?
注意:我没有进行多边处理。 我正在根据信号功率找到位置。 函数中返回的方程式为gammajk = Pj/Pk = Rk^2/Rj^2 Power ~ 1/R^2 (R为距离),功率比为gammajk = Pj/Pk = Rk^2/Rj^2 。
% pylab inline
import pylab
from scipy.optimize import fsolve
def equations(p):
# Define these outside of the function before calling this function.
global gamma01,x0,y0,gamma12,x1,y1,x2,y2,gamma10
# x,y represent the red-X & x1,y1,x2,y2,... represent Blue dots (Recievers)
x,y = p
# The returned equations are from Power ~ 1/r**2, so
# the power ratio gammajk = Pj/Pk = rk**2/rj**2.
return ( gamma01*(x1-x)**2+gamma01*(y1-y)**2-(x0-x)**2-(y0-y)**2,
gamma12*(x2-x)**2+gamma12*(y2-y)**2-(x1-x)**2-(y1-y)**2 )
gamma01 = 1.0 # Received power antenna 1 over received power antenna 0
gamma12 = 1.0 # Received power antenna 2 over received power antenna 1
x0,y0 = 0.0, 1000.0 # Position receive antenna 0
x1,y1 = 1000.0, 0.0 # Position receive antenna 1
x2,y2 = 0.0, -1000.0 # Position receive antenna 2
# Numerically solve our nonlinear system of equations
# (1.0,1.0) is the initial guessed position
x, y = fsolve(equations, (1.0, 1.0))
print('answer x y (m)',x,y)
pylab.figure()
pylab.plot([x0,x1,x2],[y0,y1,y2],'bo',markersize=8.0,label='Receive Antenna')
pylab.plot([x],[y],'rx',markersize=8.0,label='Transmitter')
pylab.axis('equal')
pylab.xlabel('x (m)')
pylab.ylabel('y (m)')
pylab.title('All Power Ratios = 1.0')
pylab.legend()
pylab.grid()
pylab.show()
情节:在蓝点之间寻找红色-x