Let's say, I have a list of x,y coordinates like:
all_coordinates = [x1,y1,x2,y2,x3,y3,x4,y4...]
And there is a method:
def rotate_xy_by_theta(self, x, y, theta):
# does the maths
returns new_x, new_y
which returns the new_x,new_y
position for each pair of coordinates given a particular x, y
input values for a given theta
.
I now want to iterate through all items in the above list in pair and generate a new list modified_coordinates
.
I can do this easily with a traditional for-loop.
Can this be done with the map
function ?
Something like:
theta = 90
modified_coordinates = map(self.rotate_xy_by_theta(x, y, theta), all_coordinates)
My issue is how to get x,y
values in pair in the above map
function.