fork download
  1. from math import sin, cos, pi
  2.  
  3.  
  4. def points(n):
  5. x, y = 1, 0
  6. yield x, y
  7.  
  8. angle = 2 * pi / n
  9. sin_a = sin(angle)
  10. cos_a = cos(angle)
  11.  
  12. for _ in range(n):
  13. x, y = (
  14. x * cos_a - y * sin_a,
  15. x * sin_a + y * cos_a
  16. )
  17. yield x, y
  18.  
  19.  
  20. for x, y in points(8):
  21. print('{:.3f} {:.3f}'.format(x, y))
  22.  
Success #stdin #stdout 0.04s 9452KB
stdin
Standard input is empty
stdout
1.000 0.000
0.707 0.707
0.000 1.000
-0.707 0.707
-1.000 0.000
-0.707 -0.707
-0.000 -1.000
0.707 -0.707
1.000 -0.000