1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| >>> x1, y1 = 20, 30
>>> x2, y2 = 180, 170
>>> can.create_line(x1, y1, x2, y2)
7
>>> x1p = x1 -xrot # chgmt de repère: translation
>>> x2p = x2 -xrot
>>> y1p = y1 -yrot
>>> y2p = y2 -yrot
>>> x1p, y1p, x2p, y2p
(-80, -70, 80, 70)
>>> from math import *
>>> ang = pi / 3
>>> ang
1.0471975511965976
>>> x1p2 = x1p*cos(ang) + y1p*sin(ang) # rotation proprement dite
>>> x2p2 = x2p*cos(ang) + y2p*sin(ang)
>>> y1p2 = -x1p*sin(ang) + y1p*cos(ang)
>>> y2p2 = -x2p*sin(ang) + y2p*cos(ang)
>>> x1p2 += xrot # retour au repère du Canvas
>>> x2p2 += xrot
>>> y1p2 += yrot
>>> y2p2 += yrot
>>> can.coords(7, x1p2, y1p2, x2p2, y2p2)
[]
>>> x1p2, y1p2, x2p2, y2p2
(-0.6217782649107164, 134.28203230275508, 200.62177826491072, 65.71796769724492)
>>> |
Partager