I'm currently developing a pygame based go to goal behavior. I approached the goal by Euclidean distance and vectorized mathematics. Here is the code
def move(roborect,i): no_plants=len(test_x) if(no_plants>i): dx = 8*test_x[i]-roborect.x dy = test_y[i]-roborect.y distance = math.sqrt(dx*dx + dy*dy) print(distance) if distance > 70: vx = dx * 2/ distance vy = dy * 2 / distance #print(vx,vy) #print(roborect.x,roborect.y) roborect.x += vx roborect.y += vy else: return 1
But I could not understand to approach the orientation of the robot towards to goal.Please help.