How to mesh specific points ?

edited February 2014 in Questions about Code

Hi :)

I am trying to use the 'Computational Geometry' library (thecloudlab.org/processing/library.html)

in a sketch that uses a generated point cloud, and not random point cloud as in the example below:

import ComputationalGeometry.*;

//Constructing the IsoSurface
IsoSurface iso = new IsoSurface(this, new PVector(0,0,0), new PVector(100,100,100), 8);

// Adding data to Isosurface
for(int i=0; i<10; i++){
  PVector pt = new PVector( random(100), random(100), random(100) );
  iso.addPoint(pt);

  // Alternate: add a point with a weighting factor
  // iso.addPoint(pt, random(0,1)); 
}

// Plotting 
iso.plot(mouseX/10000.0);

What I have is a network system of points, created with Traer Physics..an excerpt:

        void drawNetwork()
        {      
          // finds a node within the system and draws a new node branching from that point

          for ( int i = 0; i < physics.numberOfParticles(); ++i )
          {
            Particle v = physics.getParticle( i );
             wrap.addPt( new PVector(v.position().x(), v.position().y(), v.position().z() ) );

etc..

The particle 'v' should be inserted into iso.addPoint to create an isosurface that is updated in realtime, whenever a new point is added. Its (x,y,z) should be put in the 'new PVector( random(100), random(100), random(100) )', that much I understand, but how do I make the initial constructor hold the space of my point cloud?

Also, I am trying to do the same thing with another example from the library, this one makes the iso skeleton :

//Constructing the IsoSkeleton
IsoSkeleton skeleton = new IsoSkeleton(this);

// Create points to make the network
PVector[] pts = new PVector[50];
for (int i=0; i<pts.length; i++) {
  pts[i] = new PVector(random(-100, 100), random(-100, 100), random(-100, 100) );
}  

// Add edges to IsoSkeleton
for (int i=0; i<pts.length; i++) {
  for (int j=i+1; j<pts.length; j++) {
    if (pts[i].dist( pts[j] ) < 60) {
      skeleton.addEdge(pts[i], pts[j]);
    }
  }
}

Instead of using random points to add edges, I want to use something like:

// draw branching lines that connect each new node 
  stroke(0);
  strokeWeight (.5);
  beginShape( LINES );
  PVector[] pts = new PVector[physics.numberOfSprings()];
  for ( int i = 0; i < physics.numberOfSprings(); ++i )
  {
    Spring e = physics.getSpring( i );
    Particle a = e.getOneEnd();
    Particle b = e.getTheOtherEnd();

where the particles serve as skeleton points..

Sorry for the rather long post; Would be great if I could get some help! Thanks in advance! :)

Sign In or Register to comment.