package io.measures.passage.geometry;

/**
 * Point2D
 * @author Dietrich Featherston
 */
public class Point2D implements Projectable2D {

    private final float x, y;

    public Point2D(float x, float y) {
        this.x = x;
        this.y = y;
    }

    public float x() { return x; }
    public float y() { return y; }

    @Override
    public Projectable2D add(Projectable2D b) {
        return new Point2D(x + b.x(), y + b.y());
    }

    @Override
    public Projectable2D sub(Projectable2D b) {
        return new Point2D(x - b.x(), y - b.y());
    }

    @Override
    public Projectable2D mid(Projectable2D b) {
        return new Point2D((x + b.x())/2f, (y + b.y())/2f);
    }

    public float[] toArray() {
        return new float[] { x(), y() };
    }
}

@@ -32,16 +32,56 @@
 metry;%0A%0A
+import com.google.common.base.Objects;%0A%0A
 /**%0A * P
@@ -804,11 +804,152 @@
 %7D;%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        return Objects.toStringHelper(Point2D.class).add(%22x%22, x).add(%22y%22, y).toString();%0A    %7D
 %0A%7D%0A

add toString() for Point2D