Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- #rotation function
- def rotate(coordinates,angle):
- #convert the coordinates from dictionary to integers
- x = coordinates['x']
- y = coordinates['y']
- #apply the rotation matrix
- Xn = x * math.cos(angle) - y * math.cos(angle)
- Yn = x * math.sin(angle) + y * math.cos(angle)
- #return the new coordinates in dictionary format
- return {'x': Xn , 'y': Yn}
- AircraftCarrier = [{'x':0,'y':0},{'x':0,'y':-1},{'x':0,'y':-2},{'x':0,'y':-3},{'x':-1,'y':-3},{'x':1,'y':-3}]
- for panel in AircraftCarrier:
- print rotate(panel,(math.pi*3/2))
Advertisement
Add Comment
Please, Sign In to add comment