View Javadoc

1   /* File Conic2D.java 
2    *
3    * Project : Java Geometry Library
4    *
5    * ===========================================
6    * 
7    * This library is free software; you can redistribute it and/or modify it 
8    * under the terms of the GNU Lesser General Public License as published by
9    * the Free Software Foundation, either version 2.1 of the License, or (at
10   * your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful, but 
13   * WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14   * or FITNESS FOR A PARTICULAR PURPOSE.
15   *
16   * See the GNU Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public License
19   * along with this library. if not, write to :
20   * The Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21   * Boston, MA 02111-1307, USA.
22   */
23  
24  // package
25  
26  package math.geom2d.conic;
27  
28  import math.geom2d.AffineTransform2D;
29  import math.geom2d.Box2D;
30  import math.geom2d.curve.CurveSet2D;
31  import math.geom2d.domain.Boundary2D;
32  import math.geom2d.domain.ContinuousOrientedCurve2D;
33  
34  // Imports
35  
36  /**
37   * Interface for all conic curves: parametric conics, or ellipses, parabolas,
38   * and hyperbolas. Degenerate conics are also encompassed by this interface.
39   */
40  public interface Conic2D extends Boundary2D {
41  
42      // ===================================================================
43      // constants
44  
45      /**
46       * The different types of conic.
47       */
48      public enum Type {
49          /**
50           * Degenerate conic, for example a conic given by the equation
51           * <code>x^2+1=0</code>)
52           */
53          NOT_A_CONIC,
54          /** Ellipse */
55          ELLIPSE,
56          /** Hyperbola */
57          HYPERBOLA,
58          /** Parabola */
59          PARABOLA,
60          /** Circle */
61          CIRCLE,
62          /** Straight Line */
63          STRAIGHT_LINE,
64          /** Union of two lines */
65          TWO_LINES,
66          /** Single point */
67          POINT;
68      }
69  
70      // ===================================================================
71      // class variables
72  
73      // ===================================================================
74      // constructors
75  
76      // ===================================================================
77      // accessors
78  
79      // type accessors ------------
80  
81      public abstract Type getConicType();
82  
83      /**
84       * Returns the coefficient of the Cartesian representation of the conic.
85       * Cartesian equation has the form :
86       * <p>
87       * a*x^2 + b*x*y + c*y^2 + d*x + e*y + f
88       * <p>
89       * The length of the array is then of size 6.
90       */
91      public abstract double[] getConicCoefficients();
92  
93      /**
94       * Returns the eccentricity of the conic.
95       */
96      public abstract double getEccentricity();
97  
98      // ===================================================================
99      // modifiers
100 
101     public abstract Conic2D getReverseCurve();
102 
103     public abstract Conic2D transform(AffineTransform2D trans);
104 
105     public abstract CurveSet2D<? extends ContinuousOrientedCurve2D> clip(
106             Box2D box);
107 }