Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

my rotation matrix for numpy (python) isn't working

Tags:

python

numpy

i was making a program to display matrices under various transforms, and all of them work except for my rotation matrix. ive tried fiddling with it, but nothing seems to work

y = input("how many degrees do you want to rotate the shape around the origin?:    ")
j = array([(cos(int(y)), -sin(int(y))), (sin(int(y)), cos(int(y)))])
print(j.dot(w))
input("enter to exit")
like image 678
goomba Avatar asked Dec 16 '22 01:12

goomba


1 Answers

As the python documentation for cos and sin point out, the arguments should be in radians, not degrees.

You can use the math.radians function to convert degrees to radians.

like image 139
srgerg Avatar answered Dec 18 '22 15:12

srgerg