aherbert commented on PR #218:
URL: https://github.com/apache/commons-geometry/pull/218#issuecomment-1684893275

   I think the cache of the quadrilateral can be improved. It only has to be 
rebuilt if the 4 points for the extrema have changed. Here the builder is 
recreating it each time. IIUC if the corners change then you can rebuild the 
quadrilateral and add to the candidates. The rest of the work in `append` is 
not relevant and you can simply return. This can be done by returning a 
`boolean` from `checkCorners`, e.g.
   
   ```java
   public Builder append(Vector2D point) {
       // Checks if the given point supersedes one of the corners.
       if (checkCorners(point)) {
           buildQuadrilateral(minY, maxX, maxY, minX);
           return this;
       }
   
       // if the quadrilateral is not well formed, e.g. only 2 points, do not 
attempt to reduce
       if (quadrilateral.size() < 3) {
           // Point cannot yet be dismissed.
           candidates.add(point);
           return this;
       }
   
       // check all points if they are within the quadrilateral
       // in which case they can not be part of the convex hull
       if (!insideQuadrilateral(point, quadrilateral)) {
           candidates.add(point);
       }
   
       return this;
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to