Skip to content

Instantly share code, notes, and snippets.

@bavardage
Created February 16, 2010 15:06
Show Gist options
  • Select an option

  • Save bavardage/305577 to your computer and use it in GitHub Desktop.

Select an option

Save bavardage/305577 to your computer and use it in GitHub Desktop.
from math import cos, sin, pi
def rotate(pos, theta):
x,y = pos
c = cos(theta)
s = sin(theta)
return (x*c + y*s, x*s - y*c)
# example
# rotate((1,0), pi/4)
# (0.70710678118654757, 0.70710678118654746)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment