sghr / iGeo

iGeo: Computational Design and 3D Modeling Library for Processing
http://igeo.jp
GNU Lesser General Public License v3.0
146 stars 34 forks source link

HELP creating 3D Delaunay #13

Open pjetrusp opened 9 years ago

pjetrusp commented 9 years ago

I am having troubles understanding how to use 3d Delaunay class in IGEO for processing. I Understand the part of creating tetrahedrons, but I can not figure it out after that. Also, I would like to ask why is processing running much slower once delaunay class is used?

sghr commented 9 years ago

If you are talking about IDelaunay.getTetrahedron(IVec[]), it returns an array of 4 points which represents each tetrahedron-shaped cell as 4 vertices, and you'd build lines, surfaces or meshes out of them if you want. Below is an example. It'd be heavy to run delaunay with many points because of its 5D loop but I don't know why it'd make it slower after finishing it unless you make lots of geometries along it.

import igeo.*; size(800,600,IG.GL); IVec[] pts = new IVec[100]; for(int i=0; i<pts.length; i++){ pts[i] = IRand.pt(100); } IVec[][] vtx = IDelaunay.getTetrahedron(pts); for(int i=0; i<vtx.length; i++){ IColor c = IRand.clr(); new ISurface(vtx[i][0],vtx[i][1],vtx[i][2]).clr(c); new ISurface(vtx[i][0],vtx[i][1],vtx[i][3]).clr(c); new ISurface(vtx[i][0],vtx[i][2],vtx[i][3]).clr(c); new ISurface(vtx[i][1],vtx[i][2],vtx[i][3]).clr(c); }

pjetrusp commented 9 years ago

Thank you for your kind reply. Could you elaborate on other two components, and their use in creating delaunay triangulation. To be more specific, I am trying to triangulate a surface, which has a number on points on it.