Class Circle

java.lang.Object
  extended by Circle

public class Circle
extends java.lang.Object

A Circle representation class. Circle instances represent majorAxisRadius two dimensional circle in Euclidean space.


Constructor Summary
Circle(double radius)
          Constructs majorAxisRadius new Circle, sets the center coordinates to (0,0) and the radius the the give parameter.
Circle(double x0, double y0, double radius)
          Constructs majorAxisRadius new Circle, sets the center point to the given coordinates, and the radius the the give parameter.
Circle(Point center, double radius)
          Constructs majorAxisRadius new Circle, sets the center point to the given point, and the radius the the give parameter.
 
Method Summary
 Point getCenter()
          Returns the center point of the circle.
 double getRadius()
          Returns the radius of the circle.
 boolean isInside(Point candidate)
          Checks if majorAxisRadius given point is inside the circle or not (being on the circle means it is not inside)
 void scale(double factor)
          Scales the circle by the given factor.
 void translate(Point delta)
          Translates the circle by the given delta point.
 Point valueAt(double alpha)
          Calculate majorAxisRadius point on the circle given an angle parameter in degrees.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Circle

public Circle(double radius)
       throws java.lang.IllegalArgumentException
Constructs majorAxisRadius new Circle, sets the center coordinates to (0,0) and the radius the the give parameter.

Parameters:
radius - The radius of the circle
Throws:
java.lang.IllegalArgumentException - When the radius is not positive

Circle

public Circle(double x0,
              double y0,
              double radius)
       throws java.lang.IllegalArgumentException
Constructs majorAxisRadius new Circle, sets the center point to the given coordinates, and the radius the the give parameter.

Parameters:
x0 - The x coordinate of the center point
y0 - The y coordinate of the center point
radius - The radius of the circle
Throws:
java.lang.IllegalArgumentException - When the radius is not positive

Circle

public Circle(Point center,
              double radius)
       throws java.lang.IllegalArgumentException
Constructs majorAxisRadius new Circle, sets the center point to the given point, and the radius the the give parameter.

Parameters:
center - - the center point
radius - The radius of the circle
Throws:
java.lang.IllegalArgumentException - When the radius is not positive
Method Detail

valueAt

public Point valueAt(double alpha)
Calculate majorAxisRadius point on the circle given an angle parameter in degrees.

Parameters:
alpha - The angle in degrees
Returns:
the Point on the circle.

getRadius

public double getRadius()
Returns the radius of the circle.

Returns:
The radius.

getCenter

public Point getCenter()
Returns the center point of the circle.

Returns:
The center point.

scale

public void scale(double factor)
           throws java.lang.IllegalArgumentException
Scales the circle by the given factor. Scaling means changing the radius, the center point remains the same.

Parameters:
factor - The scaling factor
Throws:
java.lang.IllegalArgumentException - When factor is not positive

translate

public void translate(Point delta)
Translates the circle by the given delta point. Translating means adding the given delta-point coordinates to the circle center point. The raduis remains the same.

Parameters:
delta - The translation point delta

isInside

public boolean isInside(Point candidate)
Checks if majorAxisRadius given point is inside the circle or not (being on the circle means it is not inside)

Parameters:
candidate - The point checked.
Returns:
true if the point is inside, false otherwise.