Algorithm applied in three.js

408 Views Asked by At

In past questions had been asked about this, I understand from reading much better algorithm. This time I have developed but I have a mistake somewhere. Here's what I've been functional, they are 7 polygons and each with an assigned value (userdata.value). Apply the formula but for some reason is not working.

the desired result is something like the following: http://prag.ma/code/d3-cartogram/#netmigrate/2011

This is the algorithm that attempts to apply (this on page 7 of the paper): http://postimg.org/image/dvok6g9ij/

This may be more explained in the following paper: http://lambert.nico.free.fr/tp/biblio/Dougeniketal1985.pdf so I define each of the polygons (are 7 polygons)

Hexagongeometry[0] = new THREE.Geometry(); 
Hexagongeometry[0].vertices.push(new THREE.Vector3(3,  3, 0.0)); 
Hexagongeometry[0].vertices.push(new THREE.Vector3( 6,  5, 0.0)); 
Hexagongeometry[0].vertices.push(new THREE.Vector3( 9,  3, 0.0)); 
Hexagongeometry[0].vertices.push(new THREE.Vector3( 9,  0, 0.0)); 
Hexagongeometry[0].vertices.push(new THREE.Vector3( 6,  -3, 0.0));
Hexagongeometry[0].vertices.push(new THREE.Vector3( 3,  0, 0.0));
Hexagongeometry[0].vertices.push(new THREE.Vector3( 3,  3, 0.0));

hexagonMesh[0].userData={value:1};  //value of polygon
hexagonMesh[0].position.set(1.5, 0.0, 4.0); 
hexagonMesh[0].geometry.verticesNeedUpdate=true;

Here I have applied the formula:

http://jsfiddle.net/3ks3bx3s/

Here I applied the algorithm according to my understanding.

Hopefully I can help, I really researched the solution but I can not yet.

0

There are 0 best solutions below