I’m trying to implement my Theta star algorithm, but first I need to implement the line-of-sight algorithm. I have implemented below my lineOFsight algorithm in Python, I don’t know how accurate it is. But when I call this function of line of sight in my program, I got the below error:

` sight = lineOfsight(elevation1,drone_height,y1,x1,y2,x2) NameError: name 'lineOfsight' is not defined `

How could I fix this error?… And Is it ture what I have coded?

My Python code below for line-of-sight Algorithm:

`from Thetastar import * def lineOfsight(elevation1,drone_height,y1,x1,y2,x2): y_size = len(elevation1) x_size = len(elevation1[0]) #Distance dy=y2-y1; dx=x2-x1; if dy < 0: dy=-dy sy=-1 else: sy=1 if dx < 0: dx=-dx sx=-1 else: sx=1 f=0 if dy >= dx: while y1 != y2: f = f + dx if f>=dy and 0<y1+(sy-1)/2 and y1+(sy-1)/2<y_size and 0<x1+(sx-1)/2 and x1+(sx-1)/2<x_size: if elevation1(y1+(sy-1)/2,x1+(sx-1)/2)> drone_height: sight = 0 return sight x1 = x1 + sx f = f - dy if 0<y1+(sy-1)/2 and y1+(sy-1)/2<y_size and 0<x1+(sx-1)/2 and x1+(sx-1)/2<x_size: if f !=0 and elevation1(y1+(sy-1)/2,x1+(sx-1)/2)> drone_height: sight = 0 return sight if 0<y1+(sy-1)/2 and y1+(sy-1)/2<y_size and 1<x1 and x1<x_size: if dx==0 and elevation1(y1+(sy-1)/2,x1)>h and E(y1+(sy-1)/2,x1-1) > drone_height: sight=0 return sight y1=y1+sy else: while x1 != x2: f=f+dy; if f>=dx and 0<y1+(sy-1)/2 and y1+(sy-1)/2<y_size and 0<x1+(sx-1)/2 and x1+(sx-1)/2<x_size: if elevation1(y1+(sy-1)/2,x1+(sx-1)/2) > drone_height: sight=0 return sight y1=y1+sy f=f-dx if 0<y1+(sy-1)/2 and y1+(sy-1)/2<y_size and 0<x1+(sx-1)/2 and x1+(sx-1)/2<x_size: if f != 0 and elevation1(y1+(sy-1)/2,x1+(sx-1)/2) > drone_height: sight=0 return sight if 1<y1 and y1<y_size and 0<x1+(sx-1)/2 and x1+(sx-1)/2<x_size: if dy==0 and elevation1(y1,x1+(sx-1)/2)>h and E(y1-1,x1+(sx-1)/2)> drone_height: sight=0 return sight x1=x1+sx sight = 1 return sight `