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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js" | |
></script> | |
<script src="https://rawgit.com/mrdoob/three.js/master/examples/js/controls/TrackballControls.js" | |
></script> | |
<script src="caos.js"></script> | |
</head> |
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
var data = []; | |
for (var i = 0; i < 80; i++) { | |
var x = 5 * ((i / 80) - 0.5); | |
var y = Math.exp(-x*x) / Math.sqrt(Math.PI); | |
data.push(y); | |
} | |
for (var j = 0; j < 20; j ++) { | |
var low = 0.7 * (1 - (j + 1) / 20); | |
console.log(data.map(function (y) { | |
return y > low ? "*" : " "; |
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
// Mersenne Twister Random Generator | |
// see: http://en.wikipedia.org/wiki/Mersenne_twister | |
var MT = function MT(seed) { | |
seed = typeof seed === "number" ? seed: Date.now(); | |
var self = Object.create(MT.prototype, { | |
mt: {value: new Array(MT.N)}, | |
index: {value: 0, writable: true}, | |
}); | |
// initialize from a seed with LCG PRNG | |
var pre = self.mt[0] = seed & MT.MASK_F; |
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 <stdint.h> | |
#include <math.h> | |
#include <stdio.h> | |
// for intel CPU: little endian byte order | |
typedef union { | |
double v; | |
uint8_t b[8]; | |
struct { | |
unsigned fl: 32; |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js" | |
></script> | |
<script src="https://rawgit.com/mrdoob/three.js/master/examples/js/controls/TrackballControls.js" | |
></script> | |
<script src="geom.js"></script> | |
<script src="stl.js"></script> |
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
var ArrowMesh = (function () { | |
"use strict"; | |
var arrowGeometry = function (length, headR, headL, barR) { | |
var barL = length - headL; | |
var bar = new THREE.CylinderGeometry(barR, barR, barL); | |
var head = new THREE.CylinderGeometry(0, headR, headL); | |
var barm = new THREE.Matrix4().makeTranslation(0, barL / 2, 0); | |
var headm = new THREE.Matrix4().makeTranslation( | |
0, barL + headL / 2, 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
// calculating PI | |
console.log(Math.PI); | |
var pi1 = function (n) { | |
// Bailey-Borwein-Plouffe | |
var r = 0; | |
for (var i = 0; i < n; i++) { | |
var b = 8 * i; | |
r += (4/(b+1) - 2/(b+4) - 1/(b+5) - 1/(b+6)) / Math.pow(16, i); | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>basic L-system</title> | |
<script src="lsystem.js"></script> | |
</head> | |
<body> | |
<canvas id="canvas" width="300" height="300" /> | |
</body> |
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
// [install] brew install icarus-verilog | |
// [compile] iverilog -o flipflop flipflop.v | |
// [simulate] vvp flipflop | |
module flipflop(input wire set, input wire reset, | |
output wire q, output wire nq); | |
nand n1(q, ~set, nq); | |
nand n2(nq, ~reset, q); | |
endmodule // flipflop | |
module main; |