Skip to content

Instantly share code, notes, and snippets.

@georules
Created December 8, 2012 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georules/4242456 to your computer and use it in GitHub Desktop.
Save georules/4242456 to your computer and use it in GitHub Desktop.
Another Inlet
{"description":"Another Inlet","endpoint":"","display":"webgl","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":false,"vim":true,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"phone.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.6041241924848383,"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}
/*
accx = ACCELEROMETER X (m/s²)
accy = ACCELEROMETER Y (m/s²)
accz = ACCELEROMETER Z (m/s²)
gyrox = GYROSCOPE X (rad/s)
gyroy = GYROSCOPE Y (rad/s)
gyroz = GYROSCOPE Z (rad/s)
light = LIGHT ( lux)
magx = MAGNETIC FIELD X (μT)
magy = MAGNETIC FIELD Y (μT)
magz = MAGNETIC FIELD Z (μT)
orientx = ORIENTATION X (°)
orienty = ORIENTATION Y (°)
orientz = ORIENTATION Z (°)
proximity = PROXIMITY ( cm)
atmosphere = ATMOSPHERIC PRESSURE (mb)
sound = SOUND LEVEL (dB)
loclat = LOCATION Latitude
loclon = LOCATION Longitude
localt = LOCATION Altitude ( m)
locspeed = LOCATION Speed ( Kmh)
locacc = LOCATION Accuracy ( m)
temp = Temperature ( °F)
level = Level (%)
voltage = Voltage (Volt)
time = Time since start in ms
*/
tributary.useThreejsControl = false;
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);
var tscale = d3.scale.linear()
.domain(d3.extent(phone, function(d) { return d.time}))
.range(["#00ff00", "#ff0000"])
.interpolate(d3.interpolateHsl);
var pr = 10;
function makeCube(t) {
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() );
/*cube.position.y = positionX;
cube.position.x = positionY;
cube.position.z = positionZ;
cube.rotation.x = rotationX;
cube.rotation.y = rotationY;
cube.rotation.z = rotationZ;*/
tributary.scene.add( cube );
return cube;
}
function trans(p) {
temp = {x:p.x,y:p.y,z:p.z};
p.z=temp.y + (0);
p.y =-temp.z + (288);
p.x=temp.y + (100);
return p;
}
function damper(p) {
p.z = Math.pow(p.z,0.24);
//p.x = Math.log(p.x);
return p;
}
var p, pm1 //current phone datum and last phone datum
var vel, oldvel = {x:0,y:0,z:0};
var pos, oldpos = {x:0,y:0,z:0};
//integrate
function euler(o,f,dt) {
var n = {
x: o.x + f.x * dt,
y: o.y + f.y * dt,
z: o.z + f.z * dt,
}
return n;
}
var c = makeCube(p.time);
for(var i = 2,l = phone.length-1;i<l;i++){
p = phone[i];
pm1 = phone[i-1];
pm2 = phone[i-2];
dt = p.time - pm1.time;
dt *= 0.00909;
pa ={x:p.accx,y:p.accy,z:p.accz};
pa1 = {x:pm1.accx,y:pm1.accy,z:pm1.accz};
pa2 = {x:pm2.accx,y:pm2.accy,z:pm2.accz};
//pa = damper(pa);
vel1 = euler(pa1, pa, dt);
vel2 = euler(pa,vel1,dt);
pos1 = euler(oldpos, vel1, dt);
pos2 = euler(pos1,vel2,dt);
//pos = trans(pos);
c.position = pos2;
oldvel=vel2;
oldpos=pos2;
}
console.log(phone.length);
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.
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