This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
printf("#include <stdio.h>\n"); | |
printf("int main()\n"); | |
printf("{\n"); | |
printf(" return 0;\n"); | |
printf("}\n"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
printf("#include <stdio.h>\n"); | |
printf("int main()\n"); | |
printf("{\n"); | |
printf(" printf(\"#include <stdio.h>\\n\");\n"); | |
printf(" return 0;\n"); | |
printf("}\n"); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int i, k; | |
char s[] = $; | |
for(i=0;s[i]!=1;++i)printf("%c",s[i]); | |
for(k=0;s[k];++k)printf("%c%d", k ? ',' : '{', s[k]); | |
printf(",0}"); | |
for(++i;s[i];++i)printf("%c",s[i]); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
with open('raw.c', 'rt') as infile: | |
raw = infile.read() | |
data = [('1' if c=='$' else str(ord(c))) for c in raw] | |
delim = raw.index('$') | |
quine = raw[:delim] + '{' + ','.join(data) + ',0}' + raw[delim+1:] | |
with open('quine.c', 'wt') as outfile: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int i, k; | |
char s[] = {35,105,110,99,108,117,100,101,32,60,115,116,100,105,111,46,104,62,10,105,110,116,32,109,97,105,110,40,41,10,123,10,32,32,32,32,105,110,116,32,105,44,32,107,59,10,32,32,32,32,99,104,97,114,32,115,91,93,32,61,32,1,59,10,32,32,32,32,102,111,114,40,105,61,48,59,115,91,105,93,33,61,49,59,43,43,105,41,112,114,105,110,116,102,40,34,37,99,34,44,115,91,105,93,41,59,10,32,32,32,32,102,111,114,40,107,61,48,59,115,91,107,93,59,43,43,107,41,112,114,105,110,116,102,40,34,37,99,37,100,34,44,32,107,32,63,32,39,44,39,32,58,32,39,123,39,44,32,115,91,107,93,41,59,10,32,32,32,32,112,114,105,110,116,102,40,34,44,48,125,34,41,59,10,32,32,32,32,102,111,114,40,43,43,105,59,115,91,105,93,59,43,43,105,41,112,114,105,110,116,102,40,34,37,99,34,44,115,91,105,93,41,59,10,32,32,32,32,114,101,116,117,114,110,32,48,59,10,125,10,0}; | |
for(i=0;s[i]!=1;++i)printf("%c",s[i]); | |
for(k=0;s[k];++k)printf("%c%d", k ? ',' : '{', s[k]); | |
printf(",0}"); | |
for(++i;s[i];++i)printf("% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# quadinterp.py - by Don Cross - https://github.com/cosinekitty | |
# | |
# Sample code for finding approximate roots of | |
# an expensive function f(t) using quadratic interpolation. | |
# This source code is public domain. Use at your own risk. | |
# | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update(dt) { | |
var b, s; | |
// Calculate the force vectors acting on all the balls: | |
// both from springs and from gravity. | |
// Start out with just the gravitational force on each ball. | |
for (b of this.ballList) { | |
b.fx = 0.0; | |
b.fy = b.mass * this.gravity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddForce() { | |
// Calculate the length of the spring. | |
const dx = this.ball2.x - this.ball1.x; | |
const dy = this.ball2.y - this.ball1.y; | |
const len = Math.sqrt(dx*dx + dy*dy); | |
// The difference between the spring's rest length and its current length | |
// tells how much it is stretched or compressed. | |
// Multiply by the spring constant to get the magnitude of the force. | |
const displacement = len - this.restLength; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GeocentricLatitude(lat) | |
{ | |
// Convert geodetic latitude 'lat' to a geocentric latitude 'clat'. | |
// Geodetic latitude is the latitude as given by GPS. | |
// Geocentric latitude is the angle measured from center of Earth between a point and the equator. | |
// https://en.wikipedia.org/wiki/Latitude#Geocentric_latitude | |
var e2 = 0.00669437999014; | |
var clat = Math.atan((1.0 - e2) * Math.tan(lat)); | |
return clat; | |
} |
OlderNewer