//vodafone call visualisation // //Tim Redfern Jan 2012 // //scale of wall 10.57x2.8m - some parts are obscured // //416 x 110 in. ~ 62400x16500 ~ 1029 mpx ~ 2945 MB ram to open // //CousinMarriageWorld.svg, nominally 940 × 470 pixels, file size: 1.99 MB //World_map_(Miller_cylindrical_projection,_blank).svg‎, nominally 634 × 477 pixels, file size: 1.84 MB //wikimedia // //http://www.vectortemplates.com/vector-world-map.php //requirements - //must be able to transform points to a new projection // maybe not through normal shape library //must be able to find a random point within the shape // //250112 so far so good, can iterate children. //safest thing is to establish that I can place a point as being inside or outside of a shape //(are they closed properly!) //If we can find points in them then we can start the main task: //connecting parts of the SVG with rows in the spreadsheet //maybe next first I should look at projections (to keep them happy) //I have a map with rectangular coords, //is easy to enough to play with the projection // public boolean contains(RGeomElem shp) // public geomerative.RRectangle getBounds() // --> this is kind of hidden. why? anyway, it should be possible to use it //another option is to use the OUTLINE of the country (as a purely geometric thing). /* http://en.wikipedia.org/wiki/3D_projection a- the 3D position of a point A that is to be projected. c- the 3D position of a point C representing the camera. O- The orientation of the camera (represented, for instance, by Tait–Bryan angles). e- the viewer's position relative to the display surface.[1] */ import processing.pdf.*; import geomerative.*; class pointMapper { float xo,xs,yo,ys; pointMapper(float _xo,float _xs,float _yo,float _ys) { xo=_xo; xs=_xs; yo=_yo; ys=_ys; } RPoint map(float _x,float _y) { //formalise float px=((_x-xo)/xs); //26)/736); float py=((_y-yo)/ys); //90)/390); //transform px=(((px-0.5)*0.25)+.25); //front half of sphere py=((py-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; //camera at 0,0,0 //screen plane at 0,0,100 //(dx-ex)(ez/dz) //(dy-ey)(ez/dz) return new RPoint(x*(100/z),y*(100/z)); } } RShape shp; pointMapper shpmap; //RRectangle cb; int whichChild,numChildren; void setup(){ println("vodaviz v0.11"); RG.init(this); size(832,220); //PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600 smooth(); float m = millis(); shp = RG.loadShape("world_countries_outlines_split.svg"); shpmap = new pointMapper(26,736,90,390); RG.ignoreStyles(); println("loaded svg in "+((millis()-m)*.001)+" seconds"); numChildren=shp.children.length; whichChild=0; } void draw() { background(0,0,0); noFill(); stroke(255); strokeWeight(.02); //RG.shape(shp); whichChild=(whichChild+1)%numChildren; //println("child "+whichChild+" of "+numChildren); //cb=shp.children[whichChild].getBounds(); float xWrap=1.0; //plot shapes at points for (int i=0;i