Advertisement
NovaYoshi

sine/cosine table generator

Feb 28th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import math
  2.  
  3. RADIUS = 8
  4. ANGLES = 32
  5. XOffset = [0]*ANGLES
  6. YOffset = [0]*ANGLES
  7.  
  8. for i in range(ANGLES):
  9.     angle = (i/ANGLES)*2*math.pi
  10.     XOffset[i] = round(math.cos(angle)*RADIUS)
  11.     YOffset[i] = round(math.sin(angle)*RADIUS)
  12.  
  13. print('const signed char CIRCLEX[]={', end='')
  14. for i in range(ANGLES):
  15.     print('%2d,' % XOffset[i], end='');
  16. print('};')
  17.  
  18. print('const signed char CIRCLEY[]={', end='')
  19. for i in range(ANGLES):
  20.     print('%2d,' % YOffset[i], end='');
  21. print('};')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement