Posted on February 26th, 2007 by Andre De Pape.
Categories: Tools & Resources.
2)
Multi-touch user interface
Infra-red technologies
Carnivore Libraries
Processing - Blob Detection
Processing - Emergant systems
Processing - Networked midi
Pulse Sensing
Sound+visuals sharing data
Comment on February 27th, 2007.
I have more stuff for mindhaus but do not have the ftp password
Comment on March 2nd, 2007.
the mindHive reclus hack as of march 2nd:
/*
* This source file is part of the Reclus program.
* Copyright (C) 2005 Giovanni Baldini.
*
* Reclus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Reclus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Reclus; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import processing.opengl.*;
float h_rot = 0, v_rot = 0, zoom = 0;
boolean active_zoom = false, show_name = false;
Cluster cluster = new Cluster(new Star(0, 0, 0, “black_hole”));
String raw_data[] = loadStrings(”/Users/tobinstewart/Desktop/mindHive/data.txt”);
void setup(){
size(1024, 768, OPENGL);
frameRate(60);
bezierDetail(30);
smooth();
emissive(255, 0, 255);
ambient(0, 0, 255);
PFont font;
font = loadFont(”Meta.vlw.gz”);
textFont(font, 16); }
void draw(){
noStroke();
background(0, 15, 45);
//fill(150, 10);
rect(width-12, 6, 8, height-6);
if(cluster.birth > 0){
//fill(100, 10);
rect(width-11, 7, 6, (height-8)*(cluster.present-cluster.birth)/(cluster.death-cluster.birth)); }
//fill(200, 50);
translate(width/2, height/2, zoom);
sphere(35);
rotateX(v_rot);
rotateY(h_rot);
//fill(50, 100, 200, 40);
stroke(255, 180, 200, 40);
lights();
cluster.draw(); }
void mouseDragged(){
float movement_ratio = 220.0;
v_rot += (pmouseY-mouseY)/movement_ratio;
h_rot += (mouseX-pmouseX)/movement_ratio; }
void mouseReleased(){}
void keyPressed(){
if(key == ‘a’) zoom += 15;
if(key == ‘z’) zoom -= 15;
if(key == ‘ ‘) show_name = !show_name; }
Link[] append(Link[] a, Link b){
int i;
Link[] c = new Link[a.length+1];
for(i=0;i
c[i] = b;
return c; }
Link[] shorten(Link[] a, int b){
int i;
if(b == 0) return a;
else{
Link[] c = new Link[a.length-b];
for(i=b;i
Star[] append(Star[] a, Star b){
int i;
Star[] c = new Star[a.length+1];
for(i=0;i
c[i] = b;
return c; }
float expSphericalX(float C0, float C1, float C2, float X0, float X1, float X2, float alpha, float r){
return (r*((X1-C1)*(X2-C2)*cos(alpha)/dist(X0, X1, C0, C1) + (X1-C1)*sin(alpha) + C0)/dist(X0, X1, X2, C0, C1, C2)); }
float expSphericalY(float C0, float C1, float C2, float X0, float X1, float X2, float alpha, float r){
return (r*(-(X0-C0)*(X2-C2)*cos(alpha)/dist(X0, X1, C0, C1) - (X0-C0)*sin(alpha) + C1)/dist(X0, X1, X2, C0, C1, C2)); }
float expSphericalZ(float C0, float C1, float C2, float X0, float X1, float X2, float alpha, float r){
return (r*((X2-C2)*sin(alpha) - dist(X0, X1, C0, C1)*cos(alpha) + C2)/dist(X0, X1, X2, C0, C1, C2)); }
class Star{
float theta, phi, r, r0, spin;
String name;
int touch_count;
int k_star_dimension = 45;
Star(float i_theta, float i_phi, float i_r, String i_name){
theta = i_theta;
phi = i_phi;
r = 1;
r0 = i_r;
name = i_name;
spin = 0;
touch_count = 1; }
void update(){
this.r0 = 500*log(1+this.touch_count)/log(40); }
void text_draw(){
text(this.name, k_star_dimension, 0); }
void draw(){
pushMatrix();
rotateY(this.theta);
rotateZ(this.phi);
translate(this.r, 0, 0);
rotateX(this.spin);
box(k_star_dimension);
if(show_name) this.text_draw();
popMatrix(); }}
class Link{
float alpha_from, alpha_to, strenght_from, strenght_to;
int id_from, id_to, birth;
String flow;
float k_linklife = 24*60*60;
float k_link_magnitudo = 50.0;
Link(int i_id_from, int i_id_to, int i_birth){
id_from = i_id_from;
id_to = i_id_to;
birth = i_birth;
alpha_from = TWO_PI*random(1);
strenght_from = k_link_magnitudo*random(1, 5);
alpha_to = TWO_PI*random(1);
strenght_to = k_link_magnitudo*random(1, 5); }
void draw(float theta0, float phi0, float r0, float theta1, float phi1, float r1){
noFill();
float C0 = r0*cos(phi0)*cos(theta0);
float C1 = r0*sin(phi0);
float C2 = -r0*cos(phi0)*sin(theta0);
float X0 = r1*cos(phi1)*cos(theta1);
float X1 = r1*sin(phi1);
float X2 = -r1*cos(phi1)*sin(theta1);
float x0 = expSphericalX(C0, C1, C2, X0, X1, X2, this.alpha_from, this.strenght_from);
float y0 = expSphericalY(C0, C1, C2, X0, X1, X2, this.alpha_from, this.strenght_from);
float z0 = expSphericalZ(C0, C1, C2, X0, X1, X2, this.alpha_from, this.strenght_from);
float x1 = expSphericalX(X0, X1, X2, C0, C1, C2, this.alpha_to, this.strenght_to);
float y1 = expSphericalY(X0, X1, X2, C0, C1, C2, this.alpha_to, this.strenght_to);
float z1 = expSphericalZ(X0, X1, X2, C0, C1, C2, this.alpha_to, this.strenght_to);
float life = (24*60*millis()/1000-this.birth)/k_linklife;
float r_component = (life < 0.5)?(life*2*255):(255);
float alpha_blend = (life < 0.5)?(255):(2*(1-life)*255);
stroke(r_component, 200, 170, alpha_blend);
bezier(C0, C1, C2, x0, y0, z0, x1, y1, z1, X0, X1, X2); }}
class Cluster {
int k_quantum_leap = 40;
int k_quantum_leap_approx = 2;
float k_quantum_leap_speed = 1/5.0;
int k_time_magnitudo_ratio = 1;
int last_input = 0, last_input_id = 0, birth = 0, present = 0, death = 0;
int speed = 24*360; // map (time elapsed * time displayed)
Star[] star = new Star[1];
Link[] link = new Link[0];
String touch_data[];
Cluster(Star i_star){
star[0] = i_star; }
void new_data(String from, String to, int time){
int id_from = 0;
if(from.substring(0,min(4, from.length())).equals("loc=")) id_from = this.get_star_id(from);
int id_to = this.get_star_id(to);
if(id_from == -1) id_from = this.create_star(from);
if(id_to == -1) id_to = this.create_star(to);
this.create_link(id_from, id_to, time); }
void read_data(){
int i;
if(this.birth == 0){
touch_data = split(raw_data[0]);
this.birth = int(touch_data[0]);
touch_data = split(raw_data[raw_data.length-1]);
this.death = int(touch_data[0]); }
this.present = this.birth + this.speed*millis()/1000;
for(i=this.last_input_id;i
if(this.speed*millis()/1000 >= this.last_input){
cluster.new_data(touch_data[2], touch_data[1], int(touch_data[0]) - this.birth);
this.last_input = int(touch_data[0]) - this.birth; }
else{
this.last_input_id = i;
i = raw_data.length; }}}
void update(){
int i, j = 0;
Link[] link_temp = new Link[0];
this.read_data();
for(i=1;i
for(i=0;i
this.star[this.link[i].id_to].touch_count++; }
else j = i; }
this.link = shorten(this.link, j);
for(i=1;i
float diff = this.star[i].r0 - this.star[i].r;
if(sq(diff) < sq(k_quantum_leap_approx)) this.star[i].r = this.star[i].r0;
else{
this.star[i].r += diff*k_quantum_leap_speed;
diff = this.star[i].r0 - this.star[i].r;
if(diff > 0) this.star[i].spin += diff*k_quantum_leap_speed/(k_quantum_leap); }}}
int get_star_id(String n){
for(int i=1;i
return -1; }
int create_star(String name){
this.star = append(this.star, new Star(PI*random(1), TWO_PI*random(1), k_quantum_leap, name));
return(this.star.length - 1); }
int create_link(int id_from, int id_to, int time){
this.link = append(this.link, new Link(id_from, id_to, time));
return(this.link.length - 1); }
void draw(){
this.update();
for(int i=1;i
for(int i=0;i
(this.link[i].id_to == 0 || this.star[this.link[i].id_to].r0*this.star[this.link[i].id_to].r != 0))
this.link[i].draw(this.star[this.link[i].id_from].theta, this.star[this.link[i].id_from].phi, this.star[this.link[i].id_from].r, this.star[this.link[i].id_to].theta, this.star[this.link[i].id_to].phi, this.star[this.link[i].id_to].r); }}}
Comments can contain some xhtml. Names and emails are required (emails aren't displayed), url's are optional.