title: How to divide a line into multiple line segments?
body: <p>I'm trying to divide a line into multiple segments. Because of that i've created a function below to try get sub points between two points. It's not quite working, but almost there. Ideally, i'd like to use it something like this:</p>
  
  <pre><code>subPoint(point1, point2, 5, 10);  // this would return the half way point
  subPoint(point1, point2, 1, 10);  // this would return a point 1 tenth towrds point2
  </code></pre>
  
  <p>Here's the rough code below - any tips or pointers very welcome.</p>
  
  <pre><code>Vector subPoint(Vector startPoint, Vector endPoint, int segment, int totalSegments) {
  
    int division = (int)(totalSegments / segment);
  
    PVector divPoint = new PVector();
  
    int midX=(int)(startPoint.x+((endPoint.x-startPoint.x)/division));
    int midY=(int)(startPoint.y+((endPoint.y-startPoint.y)/division));
  
    divPoint.set(midX, midY, 0);
  
    return(divPoint);
  }
  </code></pre>