1 /* File ContinuousCurve2D.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.curve; 27 28 // Imports 29 import java.util.*; 30 31 import math.geom2d.AffineTransform2D; 32 import math.geom2d.Box2D; 33 import math.geom2d.Vector2D; 34 import math.geom2d.polygon.Polyline2D; 35 36 /** 37 * Interface for all curves which can be drawn with one stroke. This includes 38 * closed curves (ellipses, polygon boundaries...), infinite curves (straight 39 * lines, parabolas, ...), and 'finite' curves, such as polylines, conic arcs, 40 * line segments, splines... Note that an hyperbola is compound of 2 continuous 41 * curves. 42 * <p> 43 * Such curves accept parametric representation, in the form : 44 * <code>p(t)={x(t),y(t)}</code>, with <code>t</code> contained in 45 * appropriate domain. Bounds of domain of definition can be obtained by methods 46 * <code>getT0()</code> and <code>getT1()</code>. 47 * <p> 48 */ 49 50 public interface ContinuousCurve2D extends Curve2D { 51 52 // =================================================================== 53 // general methods 54 55 /** 56 * Return true if the curve makes a loop, that is come back to starting 57 * point after covering the path. 58 */ 59 public abstract boolean isClosed(); 60 61 public Vector2D getLeftTangent(double t); 62 public Vector2D getRightTangent(double t); 63 64 /** 65 * Returns a set of smooth curves. 66 */ 67 public abstract Collection<? extends SmoothCurve2D> getSmoothPieces(); 68 69 /** 70 * Returns an approximation of the curve as a polyline with <code>n</code> 71 * line segments. If the curve is closed, the method should return an 72 * instance of Ring2D. 73 * 74 * @param n the number of line segments 75 * @return a polyline with <code>n</code> line segments. 76 */ 77 public abstract Polyline2D getAsPolyline(int n); 78 79 /** 80 * Append the path of the curve to the given path. 81 * 82 * @param path a path to modify 83 * @return the modified path 84 */ 85 public abstract java.awt.geom.GeneralPath appendPath( 86 java.awt.geom.GeneralPath path); 87 88 public abstract Curve2D getReverseCurve(); 89 90 public abstract Curve2D getSubCurve(double t0, double t1); 91 92 public abstract CurveSet2D clip(Box2D box); 93 94 public abstract Curve2D transform(AffineTransform2D trans); 95 }