summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vodaviz.pde103
1 files changed, 66 insertions, 37 deletions
diff --git a/vodaviz.pde b/vodaviz.pde
index f29001c..ea103a3 100644
--- a/vodaviz.pde
+++ b/vodaviz.pde
@@ -88,10 +88,10 @@ class pointNormalise {
yo=_yo;
ys=_ys;
}
- RPoint alise(float _x,float _y) {
+ RPoint alise(RPoint in) {
//formalise
- float px=((_x-xo)/xs)*PI*2; //26)/736);
- float py=((_y-yo)/ys)*PI; //90)/390);
+ float px=(((in.x-xo)/xs)*PI*2); //26)/736);
+ float py=((in.y-yo)/ys)*PI; //90)/390);
return new RPoint(px,py);
}
@@ -99,15 +99,27 @@ class pointNormalise {
class pointMapper {
+ RPoint map(float _x,float _y,float _r) {
//transform
- float px=(((_x-0.5)*0.25)+.25); //front half of sphere
- float py=((_y-0.5)*0.3)+0.5;
+ float px=((_x-PI)*0.25)+(PI/2); //(((_x-0.5)*0.25)+.25); //front half of sphere
+ float py=((_y-(PI/2))*0.3)+(PI/2); //((_y-0.5)*0.3)+0.5;
+
//map to 3D curve
- float r=getHeight()*4;
- float x=r*cos(px*PI*2)*(sin(py*PI)) *2;
- float z=r*sin(px*PI*2)*(sin(py*PI))-985;
- float y=r*cos(py*PI)+(getHeight()*0.5)-210;
+ float r=getHeight()*4*_r;
+ float x=r*cos(px)*(sin(py)) *2;
+ float z=r*sin(px)*(sin(py))-985;
+ float y=r*cos(py)+(getHeight()*0.5)-210;
+
+
+ /*
+ //map to small sphere
+ float r=getHeight()/2;
+ float x=r*cos(px)*(sin(py));
+ float z=r*sin(px)*(sin(py))-105;
+ float y=r*cos(py);
+ */
+
//camera at 0,0,0
//screen plane at 0,0,100
@@ -117,7 +129,7 @@ class pointMapper {
//rotate camera
return new RPoint(x*(100/z),y*(100/z));
- }
+ }
}
RShape shp;
@@ -135,8 +147,8 @@ void setup(){
println("vodaviz v0.11");
RG.init(this);
- //mode="PDF";
- size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600
+ mode="PDF";
+ size(832,220,PDF, "testoutput0602.pdf"); //P3D); //832,220); //nb pdf is 800x600
smooth();
float m = millis();
@@ -169,44 +181,58 @@ void draw() {
//for (int i=0;i<calls.countries.size();i++) {
- /*
+
+ //draw outlines
+
+
+ //stroke(255);
beginShape();
for (int k=0;k<calls.getcountry(i).outline.paths[0].commands.length;k++) {
- RPoint sp=calls.getcountry(i).outline.paths[0].commands[k].startPoint;
- RPoint dp=shpmap.map(sp.x,sp.y);
+ RPoint sp=pnorm.alise(calls.getcountry(i).outline.paths[0].commands[k].startPoint);
+ RPoint dp=shpmap.map(sp.x,sp.y,1);
vertex(dp.x+(getWidth()/2),dp.y+(getHeight()/2)); //,z); //z);
}
endShape();
- */
+ //i++;
+
+ //OR
+
+
+
//pick a random colour
//stroke(random(100)+100, random(100)+100,random(100)+100);
//for (int j=0;j<calls.countries.get(i).calls;j++) {
RPoint sp=pnorm.alise(calls.countries.get(i).getpoint(100));
RPoint ep=pnorm.alise(Ireland.getpoint(100));
- if (sp.x>0&&ep.x>0){
- RPoint Sp=shpmap.map(sp.x,sp.y);
- RPoint Ep=shpmap.map(ep.x,ep.y);
+ if (sp.x>0&&ep.x>0){ //point found
+ RPoint Sp=shpmap.map(sp.x,sp.y,1);
+ RPoint Ep=shpmap.map(ep.x,ep.y,1);
+
+ //find point along path
- //find point along path
-
- float f=0.8; //fraction along path;
- float d=acos(sin(sp.y)*sin(ep.y)+cos(sp.y)*cos(ep.y)*cos(sp.x-ep.x));
- float A=sin((1-f)*d)/sin(d);
- float B=sin(f*d)/sin(d);
- float x = A*cos(sp.y)*cos(sp.x) + B*cos(ep.y)*cos(ep.x);
- float y = A*cos(sp.y)*sin(sp.x) + B*cos(ep.y)*sin(ep.x);
- float z = A*sin(sp.y) + B*sin(ep.y);
- RPoint mp=new RPoint(atan2(y,x),atan2(z,sqrt(pow(x,2)+pow(y,2))));
-
- RPoint Mp=shpmap.map(mp.x,mp.y);
- beginShape();
- line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
- line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
- endShape();
+ float f=0.8; //fraction along path;
+ float d=acos(sin(sp.y)*sin(ep.y)+cos(sp.y)*cos(ep.y)*cos(sp.x-ep.x));
+ float A=sin((1-f)*d)/sin(d);
+ float B=sin(f*d)/sin(d);
+ float x = A*cos(sp.y)*cos(sp.x) + B*cos(ep.y)*cos(ep.x);
+ float y = A*cos(sp.y)*sin(sp.x) + B*cos(ep.y)*sin(ep.x);
+ float z = A*sin(sp.y) + B*sin(ep.y);
+ RPoint mp=new RPoint(atan2(y,x),atan2(z,sqrt(pow(x,2)+pow(y,2))));
+
+ RPoint Mp=shpmap.map(mp.x,mp.y,1.04);
+ RPoint B1=shpmap.map(sp.x,sp.y,1.04);
+ RPoint B2=shpmap.map(ep.x,ep.y,1.04);
+ beginShape();
+ //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
+ //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
+ vertex(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2));
+ bezierVertex(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),B1.x+(getWidth()/2),B1.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
+ bezierVertex(B2.x+(getWidth()/2),B2.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
+ endShape();
}
- //}
+
j=j+1;
if (j>(calls.countries.get(i).calls*.01)){
i++;
@@ -214,13 +240,16 @@ void draw() {
println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls");
j=0;
}
+
+
//}
if (i==calls.countries.size()-1) {
println("finished");
noLoop();
+ if (mode=="PDF") exit();
}
- //if (mode=="PDF") exit();
+
}
void mousePressed() {