repl.it
@kade_robertson/

PPCG #96465 - Real Chebyshev Rotation

Python 2.7

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
while 1:
    p,d=input()
    x,y=p
    s=max(x,y,-x,-y)
    d=d%(s*8or 1)
    r=[(y<s)*[2,[3,x>-s][x<s]][y>-s],[2*(y<0),3*(y<=0)][x>0]][y*y==x*x]
    while s>0<d:f=1-2*(r<2);m=abs(f*s-p[r%2]);j=d>m;p[r%2]=[p[r%2]+f*d,f*s][j];r=-~r%4;d=(d-m)*j
    print"%.4f "*2%tuple(p)