Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Created October 16, 2019 00:05
Show Gist options
  • Save cosinekitty/fa4bac12aaadac5976e9e34e41d5065e to your computer and use it in GitHub Desktop.
Save cosinekitty/fa4bac12aaadac5976e9e34e41d5065e to your computer and use it in GitHub Desktop.
Calculate 360 points equally spaced around a unit circle.
#!/usr/bin/env python3
import math
angle = math.radians(1)
a = math.cos(angle)
b = math.sin(angle)
x = 1.0
y = 0.0
for n in range(361):
print('{:3d} {:11.8f} {:11.8f}'.format(n, x, y))
x, y = (a*x - b*y), (a*y + b*x)
@cosinekitty
Copy link
Author

Here is the output of this program:

  0  1.00000000  0.00000000
  1  0.99984770  0.01745241
  2  0.99939083  0.03489950
  3  0.99862953  0.05233596
  4  0.99756405  0.06975647
  5  0.99619470  0.08715574
  6  0.99452190  0.10452846
  7  0.99254615  0.12186934
  8  0.99026807  0.13917310
  9  0.98768834  0.15643447
 10  0.98480775  0.17364818
 11  0.98162718  0.19080900
 12  0.97814760  0.20791169
 13  0.97437006  0.22495105
 14  0.97029573  0.24192190
 15  0.96592583  0.25881905
 16  0.96126170  0.27563736
 17  0.95630476  0.29237170
 18  0.95105652  0.30901699
 19  0.94551858  0.32556815
 20  0.93969262  0.34202014
 21  0.93358043  0.35836795
 22  0.92718385  0.37460659
 23  0.92050485  0.39073113
 24  0.91354546  0.40673664
 25  0.90630779  0.42261826
 26  0.89879405  0.43837115
 27  0.89100652  0.45399050
 28  0.88294759  0.46947156
 29  0.87461971  0.48480962
 30  0.86602540  0.50000000
 31  0.85716730  0.51503807
 32  0.84804810  0.52991926
 33  0.83867057  0.54463904
 34  0.82903757  0.55919290
 35  0.81915204  0.57357644
 36  0.80901699  0.58778525
 37  0.79863551  0.60181502
 38  0.78801075  0.61566148
 39  0.77714596  0.62932039
 40  0.76604444  0.64278761
 41  0.75470958  0.65605903
 42  0.74314483  0.66913061
 43  0.73135370  0.68199836
 44  0.71933980  0.69465837
 45  0.70710678  0.70710678
 46  0.69465837  0.71933980
 47  0.68199836  0.73135370
 48  0.66913061  0.74314483
 49  0.65605903  0.75470958
 50  0.64278761  0.76604444
 51  0.62932039  0.77714596
 52  0.61566148  0.78801075
 53  0.60181502  0.79863551
 54  0.58778525  0.80901699
 55  0.57357644  0.81915204
 56  0.55919290  0.82903757
 57  0.54463904  0.83867057
 58  0.52991926  0.84804810
 59  0.51503807  0.85716730
 60  0.50000000  0.86602540
 61  0.48480962  0.87461971
 62  0.46947156  0.88294759
 63  0.45399050  0.89100652
 64  0.43837115  0.89879405
 65  0.42261826  0.90630779
 66  0.40673664  0.91354546
 67  0.39073113  0.92050485
 68  0.37460659  0.92718385
 69  0.35836795  0.93358043
 70  0.34202014  0.93969262
 71  0.32556815  0.94551858
 72  0.30901699  0.95105652
 73  0.29237170  0.95630476
 74  0.27563736  0.96126170
 75  0.25881905  0.96592583
 76  0.24192190  0.97029573
 77  0.22495105  0.97437006
 78  0.20791169  0.97814760
 79  0.19080900  0.98162718
 80  0.17364818  0.98480775
 81  0.15643447  0.98768834
 82  0.13917310  0.99026807
 83  0.12186934  0.99254615
 84  0.10452846  0.99452190
 85  0.08715574  0.99619470
 86  0.06975647  0.99756405
 87  0.05233596  0.99862953
 88  0.03489950  0.99939083
 89  0.01745241  0.99984770
 90  0.00000000  1.00000000
 91 -0.01745241  0.99984770
 92 -0.03489950  0.99939083
 93 -0.05233596  0.99862953
 94 -0.06975647  0.99756405
 95 -0.08715574  0.99619470
 96 -0.10452846  0.99452190
 97 -0.12186934  0.99254615
 98 -0.13917310  0.99026807
 99 -0.15643447  0.98768834
100 -0.17364818  0.98480775
101 -0.19080900  0.98162718
102 -0.20791169  0.97814760
103 -0.22495105  0.97437006
104 -0.24192190  0.97029573
105 -0.25881905  0.96592583
106 -0.27563736  0.96126170
107 -0.29237170  0.95630476
108 -0.30901699  0.95105652
109 -0.32556815  0.94551858
110 -0.34202014  0.93969262
111 -0.35836795  0.93358043
112 -0.37460659  0.92718385
113 -0.39073113  0.92050485
114 -0.40673664  0.91354546
115 -0.42261826  0.90630779
116 -0.43837115  0.89879405
117 -0.45399050  0.89100652
118 -0.46947156  0.88294759
119 -0.48480962  0.87461971
120 -0.50000000  0.86602540
121 -0.51503807  0.85716730
122 -0.52991926  0.84804810
123 -0.54463904  0.83867057
124 -0.55919290  0.82903757
125 -0.57357644  0.81915204
126 -0.58778525  0.80901699
127 -0.60181502  0.79863551
128 -0.61566148  0.78801075
129 -0.62932039  0.77714596
130 -0.64278761  0.76604444
131 -0.65605903  0.75470958
132 -0.66913061  0.74314483
133 -0.68199836  0.73135370
134 -0.69465837  0.71933980
135 -0.70710678  0.70710678
136 -0.71933980  0.69465837
137 -0.73135370  0.68199836
138 -0.74314483  0.66913061
139 -0.75470958  0.65605903
140 -0.76604444  0.64278761
141 -0.77714596  0.62932039
142 -0.78801075  0.61566148
143 -0.79863551  0.60181502
144 -0.80901699  0.58778525
145 -0.81915204  0.57357644
146 -0.82903757  0.55919290
147 -0.83867057  0.54463904
148 -0.84804810  0.52991926
149 -0.85716730  0.51503807
150 -0.86602540  0.50000000
151 -0.87461971  0.48480962
152 -0.88294759  0.46947156
153 -0.89100652  0.45399050
154 -0.89879405  0.43837115
155 -0.90630779  0.42261826
156 -0.91354546  0.40673664
157 -0.92050485  0.39073113
158 -0.92718385  0.37460659
159 -0.93358043  0.35836795
160 -0.93969262  0.34202014
161 -0.94551858  0.32556815
162 -0.95105652  0.30901699
163 -0.95630476  0.29237170
164 -0.96126170  0.27563736
165 -0.96592583  0.25881905
166 -0.97029573  0.24192190
167 -0.97437006  0.22495105
168 -0.97814760  0.20791169
169 -0.98162718  0.19080900
170 -0.98480775  0.17364818
171 -0.98768834  0.15643447
172 -0.99026807  0.13917310
173 -0.99254615  0.12186934
174 -0.99452190  0.10452846
175 -0.99619470  0.08715574
176 -0.99756405  0.06975647
177 -0.99862953  0.05233596
178 -0.99939083  0.03489950
179 -0.99984770  0.01745241
180 -1.00000000  0.00000000
181 -0.99984770 -0.01745241
182 -0.99939083 -0.03489950
183 -0.99862953 -0.05233596
184 -0.99756405 -0.06975647
185 -0.99619470 -0.08715574
186 -0.99452190 -0.10452846
187 -0.99254615 -0.12186934
188 -0.99026807 -0.13917310
189 -0.98768834 -0.15643447
190 -0.98480775 -0.17364818
191 -0.98162718 -0.19080900
192 -0.97814760 -0.20791169
193 -0.97437006 -0.22495105
194 -0.97029573 -0.24192190
195 -0.96592583 -0.25881905
196 -0.96126170 -0.27563736
197 -0.95630476 -0.29237170
198 -0.95105652 -0.30901699
199 -0.94551858 -0.32556815
200 -0.93969262 -0.34202014
201 -0.93358043 -0.35836795
202 -0.92718385 -0.37460659
203 -0.92050485 -0.39073113
204 -0.91354546 -0.40673664
205 -0.90630779 -0.42261826
206 -0.89879405 -0.43837115
207 -0.89100652 -0.45399050
208 -0.88294759 -0.46947156
209 -0.87461971 -0.48480962
210 -0.86602540 -0.50000000
211 -0.85716730 -0.51503807
212 -0.84804810 -0.52991926
213 -0.83867057 -0.54463904
214 -0.82903757 -0.55919290
215 -0.81915204 -0.57357644
216 -0.80901699 -0.58778525
217 -0.79863551 -0.60181502
218 -0.78801075 -0.61566148
219 -0.77714596 -0.62932039
220 -0.76604444 -0.64278761
221 -0.75470958 -0.65605903
222 -0.74314483 -0.66913061
223 -0.73135370 -0.68199836
224 -0.71933980 -0.69465837
225 -0.70710678 -0.70710678
226 -0.69465837 -0.71933980
227 -0.68199836 -0.73135370
228 -0.66913061 -0.74314483
229 -0.65605903 -0.75470958
230 -0.64278761 -0.76604444
231 -0.62932039 -0.77714596
232 -0.61566148 -0.78801075
233 -0.60181502 -0.79863551
234 -0.58778525 -0.80901699
235 -0.57357644 -0.81915204
236 -0.55919290 -0.82903757
237 -0.54463904 -0.83867057
238 -0.52991926 -0.84804810
239 -0.51503807 -0.85716730
240 -0.50000000 -0.86602540
241 -0.48480962 -0.87461971
242 -0.46947156 -0.88294759
243 -0.45399050 -0.89100652
244 -0.43837115 -0.89879405
245 -0.42261826 -0.90630779
246 -0.40673664 -0.91354546
247 -0.39073113 -0.92050485
248 -0.37460659 -0.92718385
249 -0.35836795 -0.93358043
250 -0.34202014 -0.93969262
251 -0.32556815 -0.94551858
252 -0.30901699 -0.95105652
253 -0.29237170 -0.95630476
254 -0.27563736 -0.96126170
255 -0.25881905 -0.96592583
256 -0.24192190 -0.97029573
257 -0.22495105 -0.97437006
258 -0.20791169 -0.97814760
259 -0.19080900 -0.98162718
260 -0.17364818 -0.98480775
261 -0.15643447 -0.98768834
262 -0.13917310 -0.99026807
263 -0.12186934 -0.99254615
264 -0.10452846 -0.99452190
265 -0.08715574 -0.99619470
266 -0.06975647 -0.99756405
267 -0.05233596 -0.99862953
268 -0.03489950 -0.99939083
269 -0.01745241 -0.99984770
270 -0.00000000 -1.00000000
271  0.01745241 -0.99984770
272  0.03489950 -0.99939083
273  0.05233596 -0.99862953
274  0.06975647 -0.99756405
275  0.08715574 -0.99619470
276  0.10452846 -0.99452190
277  0.12186934 -0.99254615
278  0.13917310 -0.99026807
279  0.15643447 -0.98768834
280  0.17364818 -0.98480775
281  0.19080900 -0.98162718
282  0.20791169 -0.97814760
283  0.22495105 -0.97437006
284  0.24192190 -0.97029573
285  0.25881905 -0.96592583
286  0.27563736 -0.96126170
287  0.29237170 -0.95630476
288  0.30901699 -0.95105652
289  0.32556815 -0.94551858
290  0.34202014 -0.93969262
291  0.35836795 -0.93358043
292  0.37460659 -0.92718385
293  0.39073113 -0.92050485
294  0.40673664 -0.91354546
295  0.42261826 -0.90630779
296  0.43837115 -0.89879405
297  0.45399050 -0.89100652
298  0.46947156 -0.88294759
299  0.48480962 -0.87461971
300  0.50000000 -0.86602540
301  0.51503807 -0.85716730
302  0.52991926 -0.84804810
303  0.54463904 -0.83867057
304  0.55919290 -0.82903757
305  0.57357644 -0.81915204
306  0.58778525 -0.80901699
307  0.60181502 -0.79863551
308  0.61566148 -0.78801075
309  0.62932039 -0.77714596
310  0.64278761 -0.76604444
311  0.65605903 -0.75470958
312  0.66913061 -0.74314483
313  0.68199836 -0.73135370
314  0.69465837 -0.71933980
315  0.70710678 -0.70710678
316  0.71933980 -0.69465837
317  0.73135370 -0.68199836
318  0.74314483 -0.66913061
319  0.75470958 -0.65605903
320  0.76604444 -0.64278761
321  0.77714596 -0.62932039
322  0.78801075 -0.61566148
323  0.79863551 -0.60181502
324  0.80901699 -0.58778525
325  0.81915204 -0.57357644
326  0.82903757 -0.55919290
327  0.83867057 -0.54463904
328  0.84804810 -0.52991926
329  0.85716730 -0.51503807
330  0.86602540 -0.50000000
331  0.87461971 -0.48480962
332  0.88294759 -0.46947156
333  0.89100652 -0.45399050
334  0.89879405 -0.43837115
335  0.90630779 -0.42261826
336  0.91354546 -0.40673664
337  0.92050485 -0.39073113
338  0.92718385 -0.37460659
339  0.93358043 -0.35836795
340  0.93969262 -0.34202014
341  0.94551858 -0.32556815
342  0.95105652 -0.30901699
343  0.95630476 -0.29237170
344  0.96126170 -0.27563736
345  0.96592583 -0.25881905
346  0.97029573 -0.24192190
347  0.97437006 -0.22495105
348  0.97814760 -0.20791169
349  0.98162718 -0.19080900
350  0.98480775 -0.17364818
351  0.98768834 -0.15643447
352  0.99026807 -0.13917310
353  0.99254615 -0.12186934
354  0.99452190 -0.10452846
355  0.99619470 -0.08715574
356  0.99756405 -0.06975647
357  0.99862953 -0.05233596
358  0.99939083 -0.03489950
359  0.99984770 -0.01745241
360  1.00000000 -0.00000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment