/** 
 * Represents a circle in the plane.
 */
public class Circle{
	
	/** The {@code radius} of the circle. */
	private double radius;
	/** The {@code center}-Point of the circle. */
	private Point center;
	
	/**
	 * Constructs a circle in the origin of the plane with the radius 1.
	 */
	public Circle(){
		radius = 1;
		center = new Point(0,0);
	}
	/**
	 * Constructs a specified circle with
	 * @param r {@code radius}
	 * @param p {@code center}
	 */
	public Circle(double r, Point p){
		radius = r;
		center = p;
	}
	/**
	 * Constructs a circle with
	 * @param middle {@code circle}
	 * @param p a Point on the circleline
	 */
	public Circle(Point middle, Point p){
		center = middle;
		radius = center.distance(p);
	}
	/**
	 * Returns the radius
	 * @return {@code radius}
	 */
	public double getRadius() {
		return radius;
	}
	/**
	 * Returns center of the circle
	 * @return {@code center}
	 */
	public Point getCenter() {
		return center;
	}
	/**
	 * Sets radius of the circle
	 * @param radius of the circle
	 */
	public void setRadius(double radius){
		this.radius = radius;
	}
	/**
	 * Sets center of the circle
	 * @param center of the circle
	 */
	public void setCenter(Point center){
		this.center = center;
	}
	/**
	 * Clones this circle
	 * @return clone of this circle
	 */
	public Circle clone(){
		return new Circle(this.radius, this.center);
	}
	/**
	 * Returns information of this circle in a string
	 * @return string of information
	 */
	public String toString() {
		String s = ("Radius: "+radius+"  Center: "+center.toString());
		return s;
	}
	/**
	 * Calculates an returns the area of this circle
	 * @return area of circle
	 */
	public double getArea(){
		return (Math.PI*radius*radius);
	}
	/**
	 * Calculates an returns perimeter of circle
	 * @return perimeter of circle
	 */
	public double getPerimeter(){
		return (2.0*Math.PI*radius);
	}
	/**
	 * Calculates an returns Diameter
	 * @return Diameter of circle
	 */
	public double getDiameter(){
		return (2*radius);
	}
	/**
	 * Adds a Point p to the center of the circle 
	 * @param p Point to add to center
	 */
	public void translate(Point p){
		center.add(p);
		return;
	}
	/**
	 * Sets the scale of the circle
	 * @param factor to multiply with radius
	 */
	public void scale (double factor){
		radius = radius * factor;
		return;
	}
	/**
	 * Sets scale an moves center of the circle
	 * @param p Point to add to center
	 * @param factor to multiply with radius
	 */
	public void translateScale (Point p, double factor){
		this.translate(p);
		this.scale(factor);
		return;
	}
	/**
	 * Returns whether the circle includes the Point p 
	 * @param p Point to test
	 * @return whether circle includes the Point
	 */
	public boolean contains(Point p){
		if (center.distance(p)<=radius) return true;
		else return false;
	}
	/**
	 * Returns whether this circle includes the test-circle
	 * @param circle to test
	 * @return whether this includes test-circle
	 */
	public boolean contains(Circle circle){
		if (center.distance(circle.getCenter())+circle.getRadius()<=radius) return true;
		else return false;
	}
	/**
	 * Returns whether this circle intersects the test-circle
	 * @param circle to test
	 * @return whether this cirlce intersects the test-cirlce
	 */
	public boolean intersects (Circle circle){
		if (center.distance(circle.getCenter())-circle.getRadius()<=radius) return true;
		else return false;	
	}
	/**
	 * Returns whether this circle equals test-circle
	 * @param circle to test
	 * @return whether circle equals test-circle
	 */
	public boolean equals (Circle circle){
		if (circle.getCenter().equals(center) && circle.getRadius()==radius)return true;
		else return false;
	}
}