You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matt Juntunen (Jira)" <ji...@apache.org> on 2019/12/29 03:27:00 UTC

[jira] [Commented] (GEOMETRY-30) VectorBuilder?D Classes

    [ https://issues.apache.org/jira/browse/GEOMETRY-30?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17004631#comment-17004631 ] 

Matt Juntunen commented on GEOMETRY-30:
---------------------------------------

I'm closing this issue since I no longer have a compelling use case for it.

> VectorBuilder?D Classes
> -----------------------
>
>                 Key: GEOMETRY-30
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-30
>             Project: Apache Commons Geometry
>          Issue Type: Wish
>            Reporter: Matt Juntunen
>            Priority: Major
>
> We should add a {{VectorBuilder?D}} class for each dimension. These classes would have the same coordinate properties as their corresponding {{Vector}} classes but would be mutable. They would be used to build {{Vector}} instances from a number of input values without requiring a new instance to be created for each step. The primary API should look something like this:
> {code:java}
> public class VectorBuilder2D {
>     double getX();
>     VectorBuilder2D setX(double);
>     double getY();
>     VectorBuilder2D setY(double);
>     VectorBuilder2D add(Vector2D);
>     VectorBuilder2D subtract(Vector2D);
>     VectorBuilder2D multiply(double);
>     Vector2D toVector();
> }
> {code}
> A good use case for this is computing a centroid:
> {code:java}
> VectorBuilder2D builder = new VectorBuilder2D();
> for (Vector2D pt : points) {
>     builder.add(pt);
> }
> builder.multiply(1.0 / points.size());
> Vector2D centroid = builder.toVector();
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)