// (c) MIT 2003.  All rights reserved.

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	Location.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	07-XX-98
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:	Geometric modeling utility class
//
// HISTORY:     11-15-98 archon
//              Incorporated in rec.geo package
//
////////////////////////////////////////////////////////////////////////////////

package rec.geo;

import java.awt.*;
import rec.util.*;

public class Location
{
  public Location( GPoint p )
  {
    this( p, 0.0 );
  }

  public Location( GPoint p, double radius )
  {
    Assert.check( radius >= 0, "location's radius cannot be negative" );

    m_Point = new GPoint( p );
    m_Radius = radius;
  }

  public Location( double x, double y, double radius )
  {
    m_Point = new GPoint( x, y );
    m_Radius = radius;
  }

  public Location( Rectangle r )
  {
    m_Point = new GPoint( (double)r.x + ((double)r.width / 2.0),
			  (double)r.y + ((double)r.height / 2.0) );

    // Make sure radius is calculated so that the entire
    //     rectangle is enclosed by the location circle.

    m_Radius = Geometry.distance( new GPoint( r.x, r.y ), m_Point );
  }

  //////////////////////////////////////////////////////////////////////////////

  public GPoint getCenter()
  {
    return( new GPoint( m_Point ) );
  }

  public double getRadius()
  {
    return( m_Radius );
  }

  //////////////////////////////////////////////////////////////////////////////

  private GPoint m_Point;
  private double m_Radius;
}

////////////////////////////////////////////////////////////////////////////////
