/Users/lyon/j4p/src/bookExamples/ch26Graphics/CircleFcn.java

1    /** 
2     * Created by IntelliJ IDEA. 
3     * User: dlyon 
4     * Date: Feb 2, 2004 
5     * Time: 3:55:54 PM 
6     * To change this template use Options | File Templates. 
7     */ 
8    package bookExamples.ch26Graphics; 
9     
10   import java.awt.geom.Point2D; 
11    
12   public class CircleFcn implements Fcn1 { 
13       private double radius = 0; 
14       private double xc = 100; 
15       private double yc = 100; 
16    
17       CircleFcn(double radius) { 
18           this.radius = radius; 
19       } 
20    
21       CircleFcn(double xc, double yc, double radius) { 
22           this.radius = radius; 
23           this.xc = xc; 
24           this.yc = yc; 
25       } 
26    
27       public Point2D getPoint(double t) { 
28           t = 2 * Math.PI * t; 
29           float x = (float) (radius * Math.cos(t) + xc); 
30           float y = (float) (radius * Math.sin(t) + yc); 
31           return new Point2D.Float(x, y); 
32       } 
33   } 
34