/**************************************************************************
* Copyright (c) 1996 Jim Crossley
*
* Although it's unlikely that anyone would actually want it,
* permission is hereby granted, without written agreement and
* without license or royalty fees, to use, copy, modify, and
* distribute this software and its documentation for any purpose,
* provided that the above copyright notice and the following three
* paragraphs appear in all copies of this software, its documentation
* and any derivative work.
*
* In no event shall Jim Crossley or Automated Design Systems, Inc. be
* liable to any party for direct, indirect, special, incidental, or
* consequential damages arising out of the use of this software and
* its documentation.
*
* The software provided hereunder is on an "as is" basis, and neither
* Jim Crossley nor Automated Design Systems, Inc. has any obligation
* to provide maintenance, support, updates, enhancements, or modifications.
*
* Derived or altered versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
***************************************************************************/
package swirly;

import java.awt.*;

/**
 * The mystical, magical Swirly.  How does it work?  I wish I knew.
 *
 * @author Jim Crossley
 * @version 1.0, 10/17/1996
 */
class Swirly extends Swirl implements Runnable {

    /**
     * The constructor that sets the member variables.
     */
    Swirly(SwirlyLand c, int x, int y, int r, Color color, boolean direction) {
        super(c,x,y,r,color,direction);
    }

    /**
     * Repetitions constructor
     */
    Swirly(SwirlyLand c, int x, int y, int r, Color color, boolean direction, int reps) {
        super(c,x,y,r,color,direction,reps);
    }

    /**
     * Rotate the polygon.  This is what makes the Swirly swirl!
     * The magic is contained within the equations used in the addPoint method.
     */
    protected void rotate(int init) {
        p = new Polygon();
        if (clockwise) init = -init;
        for (int i=0; i < 360; i++) {
            double t = i / 360.0;
            p.addPoint((int)(x + r * t * Math.cos(8 * t * Math.PI * init)),
                       (int)(y + r * t * Math.sin(8 * t * Math.PI * init)));
        }
    }
}

