daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Bezier::draw(int levelOfDetail) {
  2.    
  3.    
  4.     connectTheDots();
  5.     int i,j,k;
  6.     Pvector::iterator p;
  7.     int controlPoints = points.size();
  8.     Pvector finalPVector;
  9.     if (points.size() > 1){
  10.  
  11.         for (i = 0; i <= levelOfDetail-1; i++){
  12.             float u = (float) i/levelOfDetail;
  13.             vector<Pvector> pointvector(controlPoints);
  14.             Pvector controlPVector;
  15.             for (p = points.begin(); p != points.end(); p++){
  16.            
  17.                 controlPVector.push_back(*p);
  18.             }
  19.             pointvector[controlPoints-1] = controlPVector;
  20.        
  21.             for (j = controlPoints-2; j >= 0; j--){
  22.                 Pvector tempPVector;
  23.                 for (k = 0; k <= j; k++){
  24.                     tempPVector.push_back(Point((1-u)*pointvector[j+1][k].x + u*pointvector[j+1][k+1].x, (1-u)*pointvector[j+1][k].y + u*pointvector[j+1][k+1].y));
  25.  
  26.                 }
  27.                 pointvector[j] = tempPVector;
  28.             }
  29.  
  30.             finalPVector.push_back(pointvector[0][0]);
  31.         }
  32.  
  33.         int finalSize = finalPVector.size();
  34.         int g;
  35.         for (g = 0; g < finalSize-1; g++){
  36.             drawLine(finalPVector[g].x, finalPVector[g].y, finalPVector[g+1].x, finalPVector[g+1].y);
  37.             printf("finalPVector x1 is %f, finalPVector y1 is %f, iteration is %i\n", finalPVector[g].x, finalPVector[g].y, g);
  38.             printf("finalPVector x2 is %f, finalPVector y2 is %f, iteration is %i\n", finalPVector[g].x, finalPVector[g].y, g);
  39.  
  40.  
  41.         }
  42.     }
  43.     /* YOUR CODE HERE */
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top