-
-
Save georules/4243430 to your computer and use it in GitHub Desktop.
Another Inlet
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
{"description":"Another Inlet","endpoint":"","display":"webgl","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"phone.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.59513888888889,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false} |
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 domain = d3.range(0,Math.PI,0.1); | |
var data = []; | |
for (i in domain) { | |
p = domain[i]; | |
data.push(Math.abs(Math.cos(p)*9.8)*(-1)); | |
}*/ | |
phone = tributary.phone | |
function cleanData(d) { | |
var field; | |
for(field in d) { | |
if(d.hasOwnProperty(field)) { | |
d[field] = parseFloat(d[field]); | |
} | |
} | |
} | |
var phone = tributary.phone; | |
phone.forEach(cleanData); | |
data=[] | |
for (d in phone) { | |
data.push(phone[d].accz); | |
} | |
//console.log(data); // simulate drop data | |
//http://newcome.wordpress.com/2009/11/04/simple-fourier-transform-in-javascript/ | |
function fourier( in_array ) { | |
var len = in_array.length; | |
var output = []; | |
for( var k=0; k < len; k++ ) { | |
var real = 0; | |
var imag = 0; | |
for( var n=0; n < len; n++ ) { | |
real += in_array[n]*Math.cos(-2*Math.PI*k*n/len); | |
imag += in_array[n]*Math.sin(-2*Math.PI*k*n/len); | |
} | |
output.push( [ real, imag ] ) | |
} | |
return output; | |
} | |
var tscale = d3.scale.linear() | |
.domain([0,data.length]) | |
.range(["#00FF00", "#FF0000"]) | |
.interpolate(d3.interpolateHsl); | |
var pr = 12; | |
function makeCube(t,pos) { | |
var col = parseInt(tscale(t).slice(1,7), 16); | |
var materials = d3.range(6).map(function(d) { | |
return new THREE.MeshBasicMaterial( { color: col } ) | |
}) | |
var cube = new THREE.Mesh( new THREE.CubeGeometry( pr, pr, pr, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() ); | |
tributary.scene.add( cube ); | |
cube.position = pos; | |
return cube; | |
} | |
var zoom = 9; | |
var newdata = []; | |
var mean = d3.mean(data); | |
for (d in data) { | |
var cube = makeCube(d,{x:d*zoom-300, y:data[d]+200 , z:0}); | |
newdata.push(data[d]-mean); | |
} | |
var f = fourier(newdata); | |
N = data.length; | |
//http://www.adamsiembida.com/node/23 | |
//http://tech.groups.yahoo.com/group/SeattleRobotics/message/44971 | |
//http://www.edaboard.com/thread107784.html | |
var locs = []; | |
for (d in f) { | |
// FFT to x in frequency domain | |
var location = Math.abs(f[d][0]) / Math.pow((2*Math.PI*N),2); | |
locs.push(location); | |
} | |
// inverse fft 1/N*fft to translate frequency back to time domain | |
ifft = fourier(locs); | |
locs = [] | |
for (l in ifft) { | |
locs.push(ifft[l][0]*N*100); | |
} | |
for (d in locs) { | |
var cube = makeCube(d,{x:d*zoom-300, y:locs[d]-100 , z:0}); | |
} | |
console.log(data); | |
console.log(locs); |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 25 columns, instead of 26. in line 1.
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
accx,accy,accz,gyrox,gyroy,gyroz,light,magx,magy,magz,orientx,orienty,orientz,proximity,atmosphere,sound,loclat,loclon,localt,locspeed,locacc,temp,level,voltage,time | |
1.3008,0.5139,9.5873,0.0171,0.0085,-0.0298,63.6197,12.3,13.9,-42.5,311.22,-2.44,-8.12,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,21, | |
1.3008,0.5139,9.5873,-0.1023,0.0128,-0.016,63.6197,12.7,14.4,-42.9,309.81,-2.24,-7.78,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,87, | |
1.2712,0.3741,9.5669,-0.1023,0.0128,-0.016,63.6197,12.7,14.4,-42.9,309.81,-2.24,-7.78,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,139, | |
1.2712,0.3741,9.5669,0.0927,0.0192,-0.0096,63.6197,12.7,14.4,-42.9,309.81,-2.24,-7.78,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,204, | |
1.2712,0.3741,9.5669,0.0927,0.0192,-0.0096,64.3699,12.8,13.8,-42.2,309.81,-2.24,-7.78,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,263, | |
1.2712,0.3741,9.5669,0.0927,0.0192,-0.0096,64.3699,12.8,13.8,-42.2,309.81,-2.24,-7.78,5.0,1009.2,47.812,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,314, | |
1.1611,0.429,9.725,0.0192,0.064,-0.0224,64.3699,12.8,13.8,-42.2,309.81,-2.24,-7.78,5.0,1009.2,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,374, | |
1.1611,0.429,9.725,0.0192,0.064,-0.0224,64.3699,12.8,13.8,-42.2,309.81,-2.24,-7.78,5.0,1009.2,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,424, | |
1.1544,0.5324,9.4232,-0.0139,0.0309,-0.0266,63.6197,12.4,14.1,-42.7,312.58,-2.75,-7.29,5.0,1009.18,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,500, | |
1.1544,0.5324,9.4232,-0.0139,0.0309,-0.0266,63.6197,12.4,14.1,-42.7,312.58,-2.75,-7.29,5.0,1009.18,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,550, | |
1.1544,0.5324,9.4232,-0.0139,0.0309,-0.0266,63.6197,12.4,14.1,-42.7,312.58,-2.75,-7.29,5.0,1009.18,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,600, | |
0.1157,0.253,0.867,-1.3781,-0.1492,0.4956,63.6197,12.4,14.1,-42.7,312.58,-2.75,-7.29,5.0,1009.18,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,650, | |
0.1157,0.253,0.867,-1.3781,-0.1492,0.4956,109.0908,14.2,23.3,-39.8,312.58,-2.75,-7.29,5.0,1009.18,49.77,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,726, | |
0.0525,0.1849,0.2874,-1.0957,-0.0853,0.4999,109.0908,14.2,23.3,-39.8,312.58,-2.75,-7.29,5.0,1009.18,50.408,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,817, | |
0.0525,0.1849,0.2874,-1.0957,-0.0853,0.4999,176.4123,14.2,23.3,-39.8,312.58,-2.75,-7.29,5.0,1009.18,50.408,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,867, | |
0.0525,0.1849,0.2874,-0.3603,0.0682,0.4754,176.4123,17.5,28.7,-35.5,318.96,5.26,-7.76,5.0,1009.18,50.408,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,924, | |
0.0031,0.1974,0.7797,-0.3603,0.0682,0.4754,176.4123,17.5,28.7,-35.5,318.96,5.26,-7.76,5.0,1009.18,50.408,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,996, | |
0.0031,0.1974,0.7797,3.5717,-5.0031,-2.6561,122.6594,6.0,16.5,-44.6,318.96,5.26,-7.76,5.0,1009.18,50.408,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1085, | |
10.0106,-3.0236,14.8568,3.5717,-5.0031,-2.6561,122.6594,6.0,16.5,-44.6,318.96,5.26,-7.76,5.0,1009.18,72.464,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1161, | |
10.0106,-3.0236,14.8568,-1.2385,-0.7834,0.8143,60.7053,6.0,16.5,-44.6,318.96,5.26,-7.76,5.0,1009.18,72.464,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1218, | |
4.1395,-1.5018,3.628,-1.2385,-0.7834,0.8143,60.7053,-1.5,24.2,-43.6,322.55,9.37,-18.34,5.0,1009.18,72.464,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1313, | |
4.1395,-1.5018,3.628,0.0778,-0.2036,-0.064,60.7053,-1.5,24.2,-43.6,322.55,9.37,-18.34,5.0,1009.18,72.464,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1367, | |
4.1395,-1.5018,3.628,0.0778,-0.2036,-0.064,69.0606,-1.5,24.2,-43.6,322.55,9.37,-18.34,5.0,1009.18,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1417, | |
4.1711,-1.9985,8.3534,0.0011,-0.1077,-0.0128,69.0606,0.6,23.4,-43.7,322.55,9.37,-18.34,5.0,1009.18,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1501, | |
4.1711,-1.9985,8.3534,0.0011,-0.1077,-0.0128,69.0606,0.6,23.4,-43.7,322.55,9.37,-18.34,5.0,1009.18,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1551, | |
4.4675,-1.9419,8.2122,0.0128,-0.1247,-0.0128,69.0606,0.6,23.4,-43.7,322.55,9.37,-18.34,5.0,1009.18,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1618, | |
4.4675,-1.9419,8.2122,0.0128,-0.1247,-0.0128,70.6989,-0.3,23.2,-43.4,304.64,12.37,-29.0,5.0,1009.32,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1696, | |
4.8715,-1.8804,8.2026,-0.0373,0.0053,0.0256,70.6989,-0.3,23.2,-43.4,304.64,12.37,-29.0,5.0,1009.32,57.258,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1765, | |
4.8715,-1.8804,8.2026,-0.0373,0.0053,0.0256,70.6989,-0.3,23.2,-43.4,304.64,12.37,-29.0,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1815, | |
5.0685,-1.7291,8.113,0.3667,0.4413,0.0096,70.6989,0.4,21.3,-44.8,304.64,12.37,-29.0,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1885, | |
5.0685,-1.7291,8.113,0.3667,0.4413,0.0096,70.6989,0.4,21.3,-44.8,304.64,12.37,-29.0,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1936, | |
5.0685,-1.7291,8.113,0.3667,0.4413,0.0096,70.6989,0.4,21.3,-44.8,304.64,12.37,-29.0,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,1986, | |
4.2973,-1.7041,8.4004,0.1812,0.0565,-0.0544,65.1289,0.4,21.3,-44.8,304.64,12.37,-29.0,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2045, | |
4.2973,-1.7041,8.4004,0.1812,0.0565,-0.0544,65.1289,1.1,21.1,-44.7,301.72,9.97,-28.8,5.0,1009.32,56.448,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2127, | |
4.3636,-1.2846,8.4644,0.0277,-0.0053,0.0426,65.1289,1.1,21.1,-44.7,301.72,9.97,-28.8,5.0,1009.32,62.731,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2182, | |
4.3636,-1.2846,8.4644,0.0277,-0.0053,0.0426,62.1454,1.1,21.1,-44.7,301.72,9.97,-28.8,5.0,1009.32,62.731,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2233, | |
4.3636,-1.2846,8.4644,0.0277,-0.0053,0.0426,62.1454,1.1,21.1,-44.7,301.72,9.97,-28.8,5.0,1009.32,62.731,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2288, | |
4.1462,-1.4146,8.3451,0.1364,0.8847,-0.0096,62.8782,2.6,20.1,-44.6,298.36,9.97,-28.8,5.0,1009.32,62.731,37.96732,-122.28161,?,?,25.0,77.0,93.0,4.123,2367, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment