title: I'm working on a convex hull project using processing3, could somebody tell me if there's anyway to quit a function (not the whole program)?
body: <pre><code>    int currentPoint = 2;
      int direction = 1;
      PVector copyOf(PVector p){
          return new PVector(p.x, p.y);
      }
  
      void addPoint() {
  
          hull.add(points.get(currentPoint));
  
      // look at the turn direction in the last three points
      // (we have to work with copies of the points because Java)
          p1 = copyOf(hull.get(hull.size() - 3));
          p2 = copyOf(hull.get(hull.size() - 2));
          p3 = copyOf(hull.get(hull.size() - 1));
  
  
          while (!crossprod (p1, p2, p3) &amp;&amp; hull.size() &gt; 2) {
      // if crossproduct is &lt;= 0, then remove the middle point
      // if crossproduct is &gt;= 0, do nothing because we have add the point before
              hull.remove(hull.size() - 2);
              if (hull.size() &gt;= 3) {
      //in case of null pointer error
                  p1 = copyOf(hull.get(hull.size() - 3));
              }
              p2 = copyOf(hull.get(hull.size() - 2));
              p3 = copyOf(hull.get(hull.size() - 1));
          }
      //you'll see information in the console
          println("currentPoint: " + currentPoint + " numPoints: " + points.size() + " hullSize: " + hull.size()+" direction:"+direction);
          if (currentPoint == points.size() -1 || currentPoint == 0) {
      //when direction = 1, it's a traversal of all points with O(n)
      //when direction = -1, the construction of convex hull began which is O(nlogn)
              direction = direction * -1;
              if (currentPoint == 0){
      /****add code here*****/
              }
          }
  
          currentPoint+= direction;
      }
  </code></pre>
  
  <p>It's quite hard to explain my question clearly without code. I want to add some code so that when <code>currentPoint = 0</code>, it will quit the <code>addpoint()</code> function. <code>exit()</code> won't work, for it will quit the whole program and the animation already played will disappear. I can't think up any good solution to that, do anybody has ideas about that?</p>