Documentation of 'math.geom2d.curve.CurveArray2D' Java class
CurveArray2D
math.geom2d.curve

Class CurveArray2D<T extends Curve2D>

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<T>, Curve2D, CurveSet2D<T>, GeometricObject2D, Shape2D, ShapeSet2D<T>
    Direct Known Subclasses:
    CirculinearCurveArray2D, ContourArray2D, PolyCurve2D


    public class CurveArray2D<T extends Curve2D>
    extends java.lang.Object
    implements CurveSet2D<T>, java.lang.Iterable<T>, java.lang.Cloneable

    A parameterized set of curves. A curve cannot be included twice in a CurveArray2D.

    The k-th curve contains points with positions between 2*k and 2*k+1. This allows to differentiate extremities of contiguous curves. The points with positions t between 2*k+1 and 2*k+2 belong to the curve k if t<2*k+1.5, or to the curve k+1 if t>2*k+1.5

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      void add(int index, T curve)
      Inserts the specified shape at the specified position in this set (optional operation).
      boolean add(T curve)
      Adds the curve to the curve set, if it does not already belongs to the set.
      boolean almostEquals(GeometricObject2D obj, double eps)
      Checks if the two objects are similar up to a given threshold value.
      java.awt.Shape asAwtShape() 
      Box2D boundingBox()
      Returns bounding box for the CurveArray2D.
      T childCurve(double t)
      Returns the child curve corresponding to a given position.
      void clear()
      Clears the inner curve collection.
      CurveSet2D<? extends Curve2D> clip(Box2D box)
      Clips a curve, and return a CurveArray2D.
      CurveArray2D<? extends Curve2D> clone()
      Deprecated. 
      use copy constructor instead (0.11.2)
      boolean contains(double x, double y)
      Returns true if one of the curves contains the point
      boolean contains(Point2D p)
      Returns true if one of the curves contains the point
      boolean contains(T curve)
      Checks if the curve set contains the given curve.
      java.util.Collection<? extends ContinuousCurve2D> continuousCurves()
      Returns the collection of continuous curves which constitute this curve.
      static <T extends Curve2D>
      CurveArray2D<T>
      create(java.util.Collection<T> curves)
      Static factory for creating a new CurveArray2D from a collection of curves.
      static <T extends Curve2D>
      CurveArray2D<T>
      create(T... curves)
      Static factory for creating a new CurveArray2D from an array of curves.
      int curveIndex(double t)
      Returns the index of the curve corresponding to a given position.
      java.util.Collection<T> curves()
      Returns the collection of curves
      double distance(double x, double y)
      Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.
      double distance(Point2D p)
      Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
      void draw(java.awt.Graphics2D g2)
      Draws the curve on the given Graphics2D object.
      boolean equals(java.lang.Object obj)
      Returns true if obj is a CurveArray2D with the same number of curves, and such that each curve belongs to both objects.
      T firstCurve()
      Returns the first curve of the collection if it exists, null otherwise.
      Point2D firstPoint()
      Returns the first point of the curve.
      T get(int index)
      Returns the inner curve corresponding to the given index.
      java.awt.geom.GeneralPath getGeneralPath() 
      double getT0()
      Deprecated. 
      replaced by t0() (since 0.11.1).
      double getT1()
      Deprecated. 
      replaced by t1() (since 0.11.1).
      double globalPosition(int i, double t)
      Converts a position on a curve (between t0 and t1 of the curve) to the position on the curve set (between 0 and 2*Nc-1).
      int indexOf(T curve)
      Returns index of the given curve within the inner array.
      java.util.Collection<Point2D> intersections(LinearShape2D line)
      Returns the intersection points of the curve with the specified line.
      boolean isBounded()
      return true, if all curve pieces are bounded
      boolean isEmpty()
      Returns true if the CurveSet does not contain any curve.
      boolean isSingular(double pos)
      Checks if a point is singular.
      java.util.Iterator<T> iterator() 
      T lastCurve()
      Returns the last curve of the collection if it exists, null otherwise.
      Point2D lastPoint()
      Returns the last point of the curve.
      double localPosition(double t)
      Converts the position on the curve set, which is comprised between 0 and 2*Nc-1 with Nc being the number of curves, to the position on the curve which contains the position.
      Point2D point(double t)
      Returns the point located at the given position on the curve.
      double position(Point2D point)
      Computes the position of the point on the curve.
      double project(Point2D point)
      Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point.
      T remove(int index)
      Removes the shape at the specified position in this set (optional operation).
      boolean remove(T curve)
      Removes the specified curve from the curve set.
      Curve2D reverse()
      Returns the curve with same trace on the plane with parameterization in reverse order.
      java.util.Collection<Point2D> singularPoints()
      Computes the set of singular points as the set of singular points of each curve, plus the extremities of each curve.
      int size()
      Returns the number of curves in the collection
      CurveSet2D<? extends Curve2D> subCurve(double t0, double t1)
      Return an instance of CurveArray2D.
      double t0()
      Returns 0.
      double t1()
      Get value of parameter t for the last point of the curve.
      CurveArray2D<? extends Curve2D> transform(AffineTransform2D trans)
      Transforms each curve, and build a new CurveArray2D with the set of transformed curves.
      java.util.Collection<Point2D> vertices()
      Implementation of getVertices() for curve returns the same result as the method getSingularPoints().
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • CurveArray2D

        public CurveArray2D()
        Empty constructor. Initializes an empty array of curves.
      • CurveArray2D

        public CurveArray2D(int n)
        Empty constructor. Initializes an empty array of curves, with a given size for allocating memory.
      • CurveArray2D

        public CurveArray2D(T... curves)
        Constructor from an array of curves.
        Parameters:
        curves - the array of curves in the set
      • CurveArray2D

        public CurveArray2D(CurveSet2D<? extends T> set)
      • CurveArray2D

        public CurveArray2D(java.util.Collection<? extends T> curves)
        Constructor from a collection of curves. The curves are added to the inner collection of curves.
        Parameters:
        curves - the collection of curves to add to the set
    • Method Detail

      • create

        public static <T extends Curve2DCurveArray2D<T> create(java.util.Collection<T> curves)
        Static factory for creating a new CurveArray2D from a collection of curves.
        Since:
        0.8.1
      • create

        public static <T extends Curve2DCurveArray2D<T> create(T... curves)
        Static factory for creating a new CurveArray2D from an array of curves.
        Since:
        0.8.1
      • localPosition

        public double localPosition(double t)
        Converts the position on the curve set, which is comprised between 0 and 2*Nc-1 with Nc being the number of curves, to the position on the curve which contains the position. The result is comprised between the t0 and the t1 of the child curve.
        Specified by:
        localPosition in interface CurveSet2D<T extends Curve2D>
        Parameters:
        t - the position on the curve set
        Returns:
        the position on the subcurve
        See Also:
        globalPosition(int, double), curveIndex(double)
      • globalPosition

        public double globalPosition(int i,
                                     double t)
        Converts a position on a curve (between t0 and t1 of the curve) to the position on the curve set (between 0 and 2*Nc-1).
        Specified by:
        globalPosition in interface CurveSet2D<T extends Curve2D>
        Parameters:
        i - the index of the curve to consider
        t - the position on the curve
        Returns:
        the position on the curve set, between 0 and 2*Nc-1
        See Also:
        localPosition(double), curveIndex(double)
      • curveIndex

        public int curveIndex(double t)
        Returns the index of the curve corresponding to a given position.
        Specified by:
        curveIndex in interface CurveSet2D<T extends Curve2D>
        Parameters:
        t - the position on the set of curves, between 0 and twice the number of curves minus 1
        Returns:
        the index of the curve which contains position t
      • add

        public boolean add(T curve)
        Adds the curve to the curve set, if it does not already belongs to the set.
        Specified by:
        add in interface ShapeSet2D<T extends Curve2D>
        Parameters:
        curve - the curve to add
      • add

        public void add(int index,
                        T curve)
        Description copied from interface: ShapeSet2D
        Inserts the specified shape at the specified position in this set (optional operation).
        Specified by:
        add in interface ShapeSet2D<T extends Curve2D>
      • remove

        public boolean remove(T curve)
        Removes the specified curve from the curve set.
        Specified by:
        remove in interface ShapeSet2D<T extends Curve2D>
        Parameters:
        curve - the curve to remove
      • remove

        public T remove(int index)
        Description copied from interface: ShapeSet2D
        Removes the shape at the specified position in this set (optional operation).
        Specified by:
        remove in interface ShapeSet2D<T extends Curve2D>
      • indexOf

        public int indexOf(T curve)
        Returns index of the given curve within the inner array.
        Specified by:
        indexOf in interface ShapeSet2D<T extends Curve2D>
      • clear

        public void clear()
        Clears the inner curve collection.
        Specified by:
        clear in interface ShapeSet2D<T extends Curve2D>
      • curves

        public java.util.Collection<T> curves()
        Returns the collection of curves
        Specified by:
        curves in interface CurveSet2D<T extends Curve2D>
        Returns:
        the inner collection of curves
      • get

        public T get(int index)
        Returns the inner curve corresponding to the given index.
        Specified by:
        get in interface CurveSet2D<T extends Curve2D>
        Specified by:
        get in interface ShapeSet2D<T extends Curve2D>
        Parameters:
        index - index of the curve
        Returns:
        the i-th inner curve
        Since:
        0.6.3
      • childCurve

        public T childCurve(double t)
        Returns the child curve corresponding to a given position.
        Specified by:
        childCurve in interface CurveSet2D<T extends Curve2D>
        Parameters:
        t - the position on the set of curves, between 0 and twice the number of curves
        Returns:
        the curve corresponding to the position.
        Since:
        0.6.3
      • firstCurve

        public T firstCurve()
        Returns the first curve of the collection if it exists, null otherwise.
        Specified by:
        firstCurve in interface CurveSet2D<T extends Curve2D>
        Returns:
        the first curve of the collection
      • lastCurve

        public T lastCurve()
        Returns the last curve of the collection if it exists, null otherwise.
        Specified by:
        lastCurve in interface CurveSet2D<T extends Curve2D>
        Returns:
        the last curve of the collection
      • size

        public int size()
        Returns the number of curves in the collection
        Specified by:
        size in interface ShapeSet2D<T extends Curve2D>
        Returns:
        the number of curves in the collection
      • isEmpty

        public boolean isEmpty()
        Returns true if the CurveSet does not contain any curve.
        Specified by:
        isEmpty in interface Shape2D
        Returns:
        true if the shape does not contain any point.
      • intersections

        public java.util.Collection<Point2D> intersections(LinearShape2D line)
        Description copied from interface: Curve2D
        Returns the intersection points of the curve with the specified line. The length of the result array is the number of intersection points.
        Specified by:
        intersections in interface Curve2D
      • t0

        public double t0()
        Returns 0.
        Specified by:
        t0 in interface Curve2D
      • getT0

        @Deprecated
        public double getT0()
        Deprecated. replaced by t0() (since 0.11.1).
        Specified by:
        getT0 in interface Curve2D
      • t1

        public double t1()
        Description copied from interface: Curve2D
        Get value of parameter t for the last point of the curve. It can be +Infinity, in this case the piece of curve is not bounded.
        Specified by:
        t1 in interface Curve2D
      • getT1

        @Deprecated
        public double getT1()
        Deprecated. replaced by t1() (since 0.11.1).
        Specified by:
        getT1 in interface Curve2D
      • point

        public Point2D point(double t)
        Description copied from interface: Curve2D
        Returns the point located at the given position on the curve. If the parameter lies outside the definition range, the parameter corresponding to the closest bound is used instead. This method can be used to draw an approximated outline of a curve, by selecting multiple values for t and drawing lines between them.
        Specified by:
        point in interface Curve2D
      • singularPoints

        public java.util.Collection<Point2D> singularPoints()
        Computes the set of singular points as the set of singular points of each curve, plus the extremities of each curve. Each point is referenced only once.
        Specified by:
        singularPoints in interface Curve2D
        Returns:
        a collection of Point2D.
        See Also:
        vertices()
      • vertices

        public java.util.Collection<Point2D> vertices()
        Implementation of getVertices() for curve returns the same result as the method getSingularPoints().
        Specified by:
        vertices in interface Curve2D
        Returns:
        a collection of Point2D.
        See Also:
        singularPoints()
      • isSingular

        public boolean isSingular(double pos)
        Description copied from interface: Curve2D
        Checks if a point is singular.
        Specified by:
        isSingular in interface Curve2D
        Parameters:
        pos - the position of the point on the curve
        Returns:
        true if the point at this location is singular
      • position

        public double position(Point2D point)
        Description copied from interface: Curve2D
        Computes the position of the point on the curve. If the point does not belong to the curve, return Double.NaN. It is complementary to the point(double) method.
        Specified by:
        position in interface Curve2D
        Parameters:
        point - a point belonging to the curve
        Returns:
        the position of the point on the curve
        See Also:
        Curve2D.point(double)
      • project

        public double project(Point2D point)
        Description copied from interface: Curve2D
        Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. This function should always returns a valid value.
        Specified by:
        project in interface Curve2D
        Parameters:
        point - a point to project
        Returns:
        the position of the closest orthogonal projection
      • reverse

        public Curve2D reverse()
        Description copied from interface: Curve2D
        Returns the curve with same trace on the plane with parameterization in reverse order.
        Specified by:
        reverse in interface Curve2D
      • subCurve

        public CurveSet2D<? extends Curve2D> subCurve(double t0,
                                                      double t1)
        Return an instance of CurveArray2D.
        Specified by:
        subCurve in interface Curve2D
        Parameters:
        t0 - position of the start of the sub-curve
        t1 - position of the end of the sub-curve
        Returns:
        the portion of original curve comprised between t0 and t1.
      • distance

        public double distance(Point2D p)
        Description copied from interface: Shape2D
        Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
        Specified by:
        distance in interface Shape2D
      • distance

        public double distance(double x,
                               double y)
        Description copied from interface: Shape2D
        Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
        Specified by:
        distance in interface Shape2D
      • isBounded

        public boolean isBounded()
        return true, if all curve pieces are bounded
        Specified by:
        isBounded in interface Shape2D
      • clip

        public CurveSet2D<? extends Curve2D> clip(Box2D box)
        Clips a curve, and return a CurveArray2D. If the curve is totally outside the box, return a CurveArray2D with 0 curves inside. If the curve is totally inside the box, return a CurveArray2D with only one curve, which is the original curve.
        Specified by:
        clip in interface Curve2D
        Specified by:
        clip in interface Shape2D
        Parameters:
        box - the clipping box
        Returns:
        the clipped shape
      • boundingBox

        public Box2D boundingBox()
        Returns bounding box for the CurveArray2D.
        Specified by:
        boundingBox in interface Shape2D
        Returns:
        the bounding box of the shape.
      • continuousCurves

        public java.util.Collection<? extends ContinuousCurve2D> continuousCurves()
        Description copied from interface: Curve2D
        Returns the collection of continuous curves which constitute this curve.
        Specified by:
        continuousCurves in interface Curve2D
        Returns:
        a collection of continuous curves.
      • contains

        public boolean contains(Point2D p)
        Returns true if one of the curves contains the point
        Specified by:
        contains in interface Shape2D
      • contains

        public boolean contains(double x,
                                double y)
        Returns true if one of the curves contains the point
        Specified by:
        contains in interface Shape2D
      • getGeneralPath

        public java.awt.geom.GeneralPath getGeneralPath()
      • asAwtShape

        public java.awt.Shape asAwtShape()
        Specified by:
        asAwtShape in interface Curve2D
        Returns:
        the shape corresponding to this curve
      • draw

        public void draw(java.awt.Graphics2D g2)
        Description copied from interface: Curve2D
        Draws the curve on the given Graphics2D object.
        Specified by:
        draw in interface Curve2D
        Specified by:
        draw in interface Shape2D
        Parameters:
        g2 - the graphics to draw the curve in
      • almostEquals

        public boolean almostEquals(GeometricObject2D obj,
                                    double eps)
        Description copied from interface: GeometricObject2D
        Checks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.
        Specified by:
        almostEquals in interface GeometricObject2D
        Parameters:
        obj - the object to compare
        eps - a threshold value, for example the minimal coordinate difference
        Returns:
        true if both object have the same value up to the threshold
      • equals

        public boolean equals(java.lang.Object obj)
        Returns true if obj is a CurveArray2D with the same number of curves, and such that each curve belongs to both objects.
        Overrides:
        equals in class java.lang.Object
      • clone

        @Deprecated
        public CurveArray2D<? extends Curve2D> clone()
        Deprecated. use copy constructor instead (0.11.2)
        Specified by:
        clone in interface Curve2D
        Overrides:
        clone in class java.lang.Object
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T extends Curve2D>

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.