From ace45f1ce4960527c6dc1188b322ca5f0a5ed397 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 22 Feb 2012 17:15:09 +0000 Subject: trying great circles --- vodaviz.pde | 103 +++--------------------------------------------------------- 1 file changed, 4 insertions(+), 99 deletions(-) (limited to 'vodaviz.pde') diff --git a/vodaviz.pde b/vodaviz.pde index 89d82d1..368d2c8 100644 --- a/vodaviz.pde +++ b/vodaviz.pde @@ -94,102 +94,7 @@ cache points! import processing.pdf.*; import geomerative.*; -float log10 (float x) { - return (log(x) / log(10)); -} -class pointNormalise { - //take pixel coords and turn into lat/lng radians - float xo,xs,yo,ys; - pointNormalise(float _xo,float _xs,float _yo,float _ys) { - xo=_xo; - xs=_xs; - yo=_yo; - ys=_ys; - } - RPoint alise(RPoint p) { - //normalise - float px=(((p.x-xo)/xs)-0.5)*PI*2; //26)/736); - float py=(((p.y-yo)/ys)-0.5)*PI; //90)/390); - - return new RPoint(px,py); - } -} - -class pointTransform { - - RPoint form(RPoint in) { - //transform - return new RPoint (((in.x*0.053)+(PI/2)-.01),((in.y)*0.14)+(PI/2)-.1); //front half of sphere - } - -} - -class sphereMap { - - RPoint per(RPoint p,float _r) { - - - //map to 3D sphere - float r=getHeight()*_r; - float x=r*cos(p.x)*(sin(p.y)) *4; - float z=r*sin(p.x)*(sin(p.y)) -985; - float y=r*cos(p.y)+(getHeight()*1)-330; - - //camera at 0,0,0 - //screen plane at 0,0,100 - //(dx-ex)(ez/dz) - //(dy-ey)(ez/dz) - - //rotate camera - - //transform into 2D plane @100 - - return new RPoint(x*(100/z),y*(100/z)); - } -} - -RPoint screenMapper(RPoint p) { - p.x=((p.x*getWidth())/(PI*2))+(getWidth()/2); - p.y=((p.y*getHeight())/PI)+(getHeight()/2); - return p; -} -RPoint plerp(RPoint s,RPoint e,float a) { - return new RPoint(lerp(s.x,e.x,a),lerp(s.y,e.y,a)); -} - -float GSphereDist(RPoint p1,RPoint p2) { - return acos(sin(p1.y)*sin(p2.y)+cos(p1.y)*cos(p2.y)*cos(p1.x-p2.x)); -} - -RPoint GCircFract(RPoint sp,RPoint ep,float f) { - float d=GSphereDist(sp,ep); - 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); - return new RPoint(atan2(y,x),atan2(z,sqrt(pow(x,2)+pow(y,2)))); -} -void ellipse3d(RPoint pos,float s,float r){ - //take ellipse coord in UV space - //return in 3d globe space - float er=s*0.5; - curveTightness(-0.67); - RPoint s1=smap.per(new RPoint(pos.x-er,pos.y),r); - RPoint s2=smap.per(new RPoint(pos.x,pos.y-er),r); - RPoint s3=smap.per(new RPoint(pos.x+er,pos.y),r); - RPoint s4=smap.per(new RPoint(pos.x,pos.y+er),r); - beginShape(); - curveVertex(s1.x+hw, s1.y+hh); - curveVertex(s2.x+hw, s2.y+hh); - curveVertex(s3.x+hw, s3.y+hh); - curveVertex(s4.x+hw, s4.y+hh); - curveVertex(s1.x+hw, s1.y+hh); - curveVertex(s2.x+hw, s2.y+hh); - curveVertex(s3.x+hw, s3.y+hh); - endShape(); -} RShape shp; pointNormalise pnorm; @@ -203,7 +108,7 @@ calldata calls; bitmapcountry Ireland; bezierstroke bstroke; -linear3D gstroke; +greatcirclestroke3D gstroke; float hw,hh; @@ -214,7 +119,7 @@ void setup(){ println("vodaviz v0.6"); RG.init(this); - mode="PDF"; + //mode="PDF"; if (mode=="PDF") size(832,220,PDF, "vodaviz_lines_220212.pdf"); //P3D); //832,220); //nb pdf is 800x600 else size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600 @@ -249,7 +154,7 @@ void setup(){ float[] transpos={0.0,0.25,0.75,1.0}; float[] transamt={1.0,1.0,1.0,1.0}; //{0.5,0.05,0.05,0.5}; color col=color(0,0,0); - gstroke=new linear3D(startsize,col,smap); + gstroke=new greatcirclestroke3D(startsize,transpos,transamt,col,smap); RG.ignoreStyles(); println("loaded svg in "+((millis()-m)*.001)+" seconds"); @@ -370,7 +275,7 @@ void draw() { if (true) { //draw gradient 3D lines if (calls.countries.get(i).points.size()>0) { - for (int j=0;j