Fix polilyne sharpen vertex

I’m trying to draw a blob shape, but here is my problem, no matter what i try i’m getting this point angle

here the code that generates the points

//--------------------------------------------------------------
void ofApp::setup(){
  points = 8;
  radius = 80;
  angle = TWO_PI / points;
  
  for (unsigned int i = 0; i < points; i++){
    float x = radius * sin(angle * i);
    float y = radius * cos(angle * i);
    blob.addVertex(x, y);
  }
  blob.addVertex(radius * sin(0), radius * cos(0));
}


//--------------------------------------------------------------
void ofApp::update(){
  time = ofGetElapsedTimef() * .025;

  //  blob.clear();
  //  for (unsigned int i = 0; i < points; i++){
  //    float x = radius * sin(angle * i) * (ofNoise(time * (i + 1 * ofNoise(time * ofNoise(time)))) * 4);
  //    float y = radius * cos(angle * i) * (ofNoise(time * (i + 1 * ofNoise(time * ofNoise(time)))) * 4);
  //
  //    blob.addVertex(x, y);
  //  }
 
  for (unsigned int i = 0; i < blob.getVertices().size(); i++){
    float noise = ofNoise(time * i);
    float noiseX = ofNoise(noise);
    float noiseY = ofNoise(noise);
    
    float x = ofMap(noiseX, 0.0, 1.0, -6, 6);
    float y = ofMap(noiseY, 0.0, 1.0, -6, 6);
    
    blob.getVertices()[i].x = radius * cos(angle * (i + 1)) * x;
    blob.getVertices()[i].y = radius * sin(angle * (i + 1)) * y;
  }
  blob.getSmoothed(20, 1);
  blob.close();
  
  path.clear();
  for( int i = 0; i < blob.getVertices().size() - 1; i++) {
    path.curveTo(blob.getVertices()[i]);
  }
  path.curveTo(blob.getVertices()[blob.getVertices().size()]);
  path.simplify();
}

//--------------------------------------------------------------
void ofApp::draw(){
  ofPushMatrix();
  ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
  
//  ofNoFill();
  
  ofSetColor(124, 200, 150);
  path.draw();
  ofPopMatrix();
}

The problem is that the first point of the path is far away from the last one, and this generate the straight line.
If it can helps, you can find some code for making a blob here. https://github.com/edap/udk-2019-creative-coding/tree/master/02-shapes-Blob/src
It does not solve completely the problem of the ending point being too distant for the starting point. But it could be solved if you interpolate the radius of the last, let’s say, 10 points with the starting radius, the more you are near to the closing point, the more the radius is similar to the starting radius.

1 Like

also this line looks weird:

path.curveTo(blob.getVertices()[blob.getVertices().size()]);

note that the last point in the array is blob.getVertices().size()-1. if you want the first point, maybe you need blob.getVertices()[0]. asking for blob.getVertices()[blob.getVertices().size()] is outside of the array (it’s one larger than the last one)

I tried to rab blob.getVertices()[0] but nothing changes,.