package nl.rutgerkok.physicssimulation.shape;

import static nl.rutgerkok.physicssimulation.Vector2.vec2;

import java.util.Objects;

import nl.rutgerkok.physicssimulation.Vector2;
import nl.rutgerkok.physicssimulation.paint.Canvas;

/**
 * Represents a circle.
 *
 */
public final class Circle implements Shape {
    /**
     * Creates a new circle with the given center and radius.
     * 
     * @param center
     *            Center of the circle.
     * @param radius
     *            Radius of the circle.
     * @return The circle.
     * @throws IllegalArgumentException
     *             If the radius is not a finite number.
     */
    public static Circle circle(Vector2 center, double radius) {
        if (!Double.isFinite(radius)) {
            throw new IllegalArgumentException("Invalid radius: " + radius);
        }

        return new Circle(center, radius);
    }

    private final double radius;

    private final Vector2 center;

    private Circle(Vector2 center, double radius) {
        this.center = Objects.requireNonNull(center);
        this.radius = radius;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Circle other = (Circle) obj;
        if (!center.equals(other.center))
            return false;
        if (Double.doubleToLongBits(radius) != Double.doubleToLongBits(other.radius))
            return false;
        return true;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public Vector2 getCenter() {
        return center;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((center == null) ? 0 : center.hashCode());
        long temp;
        temp = Double.doubleToLongBits(radius);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    /**
     * Checks if this circle overlaps with another circle.
     *
     * @param that
     *            The other circle.
     * @return True if the circles overlap, false otherwise.
     */
    public boolean overlapsWith(Circle that) {
        double radiusSum = this.radius + that.radius;

        return radiusSum * radiusSum > this.center.getSquaredDistanceTo(that.center);
    }

    @Override
    public void toDrawing(Canvas canvas) {
        canvas.drawArc(center.plus(vec2(-radius, -radius)), vec2(radius * 2, radius * 2), 0, 2 * Math.PI);
    }

    @Override
    public String toString() {
        return "circle(" + center + ", " + radius + ")";
    }

    @Override
    public Shape moved(Vector2 amount) {
        return circle(center.plus(amount), radius);
    }
}

@@ -1724,32 +1724,184 @@
  center;%0A    %7D%0A%0A
+    /**%0A     * Gets the radius of this circle.%0A     * %0A     * @return The radius.%0A     */%0A    public double getRadius() %7B%0A        return radius;%0A    %7D%0A%0A
     @Override%0A  
@@ -1890,32 +1890,32 @@
 %0A%0A    @Override%0A
-
     public int h
@@ -2227,387 +2227,108 @@
     
-/**%0A     * Checks if this circle overlaps with another circle.%0A     *%0A     * @param that%0A     *            The other circle.%0A     * @return True if the circles overlap, false otherwise.%0A     */%0A    public boolean overlapsWith(Circle that) %7B%0A        double radiusSum = this.radius + that.radius;%0A%0A        return radiusSum * radiusSum %3E this.center.getSquaredDistanceTo(that.center
+@Override%0A    public Shape moved(Vector2 amount) %7B%0A        return circle(center.plus(amount), radius
 );%0A 
@@ -2545,24 +2545,24 @@
 oString() %7B%0A
+
         retu
@@ -2615,121 +2615,7 @@
    %7D
-%0A%0A    @Override%0A    public Shape moved(Vector2 amount) %7B%0A        return circle(center.plus(amount), radius);%0A    %7D
 %0A%7D%0A

Add getRadius to circle