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

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	WMGear.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	Mar 99
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:     Mechanical engineering drawing recognition
//
// HISTORY:     Mar 99  archon  created
//
////////////////////////////////////////////////////////////////////////////////

package rec.meche;

import rec.geo.*;

public class WMGear extends WPart
{
  public WMGear( GPoint center, double angle, double size, Cloneable data )
  {
    super( center, angle, size, data );
  }

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

  public Object clone()
  {
    return( new WMGear( getCenter(), getAngle(), size(), getData() ) );
  }

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

  protected GShape[] create( double size, Cloneable data )
  {
    GShape[] shapes = new GShape[9];

    double unit = size / 2.0;

    GPoint cen = new GPoint( 2.0 * unit, 2.0 * unit );

    // Create the circle.

    shapes[0] = new GCircle( cen, unit );

    // Create the horizontal and veritical spokes.

    shapes[1] = new GSegment( new GPoint( 2.0 * unit, unit ),
                              new GPoint( 2.0 * unit, 0.5 * unit ) );
    shapes[2] = new GSegment( new GPoint( 3.0 * unit, 2.0 * unit ),
                              new GPoint( 3.5 * unit, 2.0 * unit ) );
    shapes[3] = new GSegment( new GPoint( 2.0 * unit, 3.0 * unit ),
                              new GPoint( 2.0 * unit, 3.5 * unit ) );
    shapes[4] = new GSegment( new GPoint( unit, 2.0 * unit ),
                              new GPoint( 0.5 * unit, 2.0 * unit ) );

    // Create the diagonal spokes.

    shapes[5] = new GSegment( cen.locatePoint( unit, Math.PI / 4.0 ),
			      cen.locatePoint( 1.5 * unit, Math.PI / 4.0 ) );
    shapes[6] = new GSegment( cen.locatePoint( unit, Math.PI * 3.0 / 4.0 ),
			      cen.locatePoint( 1.5 * unit,
					       Math.PI * 3.0 / 4.0 ) );
    shapes[7] = new GSegment( cen.locatePoint( unit, Math.PI * 5.0 / 4.0 ),
			      cen.locatePoint( 1.5 * unit,
					       Math.PI * 5.0 / 4.0 ) );
    shapes[8] = new GSegment( cen.locatePoint( unit, Math.PI * 7.0 / 4.0 ),
			      cen.locatePoint( 1.5 * unit,
					       Math.PI * 7.0 / 4.0 ) );

    return( shapes );
  }
}

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