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

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	GCircledSegment.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	Apr 99 
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:	Geometric modeling
//
// HISTORY:     Apr 99  archon  created
//
////////////////////////////////////////////////////////////////////////////////

package rec.geo;

import java.awt.*;

public class GCircledSegment extends GSegment
{
  public GCircledSegment( GPoint head, GPoint tail, double radius )
  {
    super( head, tail );

    m_Radius = radius;
  }

  public GCircledSegment( GPoint gp, double intercept, double radius )
  {
    super( gp, intercept );

    m_Radius = radius;
  }

  public GCircledSegment( GSegment gs, double radius )
  {
    super( gs );

    m_Radius = radius;
  }

  public GCircledSegment( GCircledSegment gs )
  {
    super( gs );

    m_Radius = gs.m_Radius;
  }

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

  public GShape copy()
  {
    return( new GCircledSegment( this ) );
  }

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

  public void display( Graphics g )
  {
    int counts = (int)Math.floor( getLength() / m_Radius / 2.0 );
    int circum = (int)Math.floor( 2.0 * m_Radius );

    GPoint head = getHeadPoint();
    GPoint tail = getTailPoint();

    double angle = Geometry.angle( head, tail );

    g.drawOval( head.getIntX(), head.getIntY(), circum, circum );

    for( int i = 1; i < counts + 1; ++i ) {

      head = head.locatePoint( 2.0 * m_Radius, angle );

      g.drawOval( head.getIntX(), head.getIntY(), circum, circum );
    }
  }

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

  private double m_Radius;
}

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