Ellipse2D
math.geom2d.conic

Class Ellipse2D

    • Constructor Detail

      • Ellipse2D

        public Ellipse2D()
        Empty constructor, define ellipse centered at origin with both major and minor semi-axis with length equal to 1.
      • Ellipse2D

        public Ellipse2D(Point2D center,         double l1,         double l2)
        Main constructor: define center by a point plus major and minor semi axis
      • Ellipse2D

        public Ellipse2D(double xc,         double yc,         double l1,         double l2)
        Define center by coordinate, plus major and minor semi axis
      • Ellipse2D

        public Ellipse2D(Point2D center,         double l1,         double l2,         double theta)
        Define center by point, major and minor semi axis lengths, and orientation angle.
      • Ellipse2D

        public Ellipse2D(double xc,         double yc,         double l1,         double l2,         double theta)
        Define center by coordinate, major and minor semi axis lengths, and orientation angle.
      • Ellipse2D

        public Ellipse2D(double xc,         double yc,         double l1,         double l2,         double theta,         boolean direct)
        Define center by coordinate, major and minor semi axis lengths, orientation angle, and boolean flag for directed ellipse.
      • Ellipse2D

        public Ellipse2D(Ellipse2D ellipse)
        construct an ellipse from the java.awt.geom class for ellipse.
    • Method Detail

      • create

        public static Ellipse2D create(Point2D focus1,               Point2D focus2,               double chord)
        Create a new Ellipse by specifying the two focii, and the length of the chord. The chord equals the sum of distances between a point of the ellipse and each focus.
        Parameters:
        focus1 - the first focus
        focus2 - the second focus
        chord - the sum of distances to focii
        Returns:
        a new instance of Ellipse2D
      • create

        @Deprecatedpublic static Ellipse2D create(Point2D center,                          double l1,                          double l2)
        Deprecated. since 0.11.1
        Main constructor: define center by a point plus major and minor semi axis
      • create

        @Deprecatedpublic static Ellipse2D create(Point2D center,                          double l1,                          double l2,                          double theta)
        Deprecated. since 0.11.1
        Define center by point, major and minor semi axis lengths, and orientation angle.
      • create

        public static Ellipse2D create(Point2D center,               double l1,               double l2,               double theta,               boolean direct)
        Define center by point, major and minor semi axis lengths, orientation angle, and boolean flag for direct ellipse.
      • create

        @Deprecatedpublic static Ellipse2D create(Ellipse2D ellipse)
        Deprecated. since 0.11.1
        Constructs an ellipse from the java.awt.geom class for ellipse.
      • reduceCentered

        public static Ellipse2D reduceCentered(double[] coefs)
        Creates a new Ellipse by reducing the conic coefficients, assuming conic type is ellipse, and ellipse is centered.
        Parameters:
        coefs - an array of double with at least 3 coefficients containing coefficients for x^2, xy, and y^2 factors.
        Returns:
        the Ellipse2D corresponding to given coefficients
      • transformCentered

        public static Ellipse2D transformCentered(Ellipse2D ellipse,                          AffineTransform2D trans)
        Transform an ellipse, by supposing both the ellipse is centered and the transform has no translation part.
        Parameters:
        ellipse - an ellipse
        trans - an affine transform
        Returns:
        the transformed ellipse, centered around origin
      • getRho

        public double getRho(double angle)
        Return the RHO parameter, in a polar representation of the ellipse, centered at the center of ellipse.
        Parameters:
        angle - : angle from horizontal
        Returns:
        distance of ellipse from ellipse center in direction theta
      • projectedVector

        public Vector2D projectedVector(Point2D point,                       double eMax)
        Compute projection of a point onto an ellipse. Return the polar vector representing the translation from point point to its projection on the ellipse, with the direction parallel to the local normal to the ellipse. The parameter rho of the PolarVector2D is positive if point lies Refs :

        http://www.spaceroots.org/documents/distance/distance-to-ellipse.pdf, http://www.spaceroots.org/downloads.html

        Parameters:
        point -
        eMax -
        Returns:
        the projection vector
      • parallel

        public Ellipse2D parallel(double d)
        Return the parallel ellipse located at a distance d from this ellipse. For direct ellipse, distance is positive outside of the ellipse, and negative inside
      • isDirect

        public boolean isDirect()
        Returns true if ellipse has a direct orientation.
        Specified by:
        isDirect in interface EllipseShape2D
      • isCircle

        public boolean isCircle()
        Returns true if this ellipse is similar to a circle, i.e. has same length for both r1 and r2.
        Specified by:
        isCircle in interface EllipseShape2D
      • semiMajorAxisLength

        public double semiMajorAxisLength()
        Returns the length of the major semi-axis of the ellipse.
      • semiMinorAxisLength

        public double semiMinorAxisLength()
        Returns the length of the minor semi-axis of the ellipse.
      • focus1

        public Point2D focus1()
        Return the first focus. It is defined as the first focus on the Major axis, in the direction given by angle theta.
      • focus2

        public Point2D focus2()
        Returns the second focus. It is defined as the second focus on the Major axis, in the direction given by angle theta.
      • vector1

        public Vector2D vector1()
        Returns the first direction vector of the ellipse, in the direction of the major axis.
      • vector2

        public Vector2D vector2()
        Returns the second direction vector of the ellipse, in the direction of the minor axis.
      • angle

        public double angle()
        Returns the angle of the ellipse first axis with the Ox axis.
      • conicCoefficients

        public double[] conicCoefficients()
        Returns the conic coefficients of the ellipse. Algorithm taken from http://tog.acm.org/GraphicsGems/gemsv/ch2-6/conmat.c
        Specified by:
        conicCoefficients in interface Conic2D
      • eccentricity

        public double eccentricity()
        Computes eccentricity of ellipse, depending on the lengths of the semi-axes. Eccentricity is 0 for a circle (r1==r2), and tends to 1 when ellipse elongates.
        Specified by:
        eccentricity in interface Conic2D
      • domain

        public Domain2D domain()
        Description copied from interface: Boundary2D
        Returns the domain delimited by this boundary.
        Specified by:
        domain in interface Boundary2D
        Returns:
        the domain delimited by this boundary
      • fill

        public void fill(Graphics2D g2)
        Description copied from interface: Boundary2D
        Fills the interior of the boundary, using the Graphics current Paint.
        Specified by:
        fill in interface Boundary2D
        Parameters:
        g2 - the Graphics to fill on
      • windingAngle

        public double windingAngle(Point2D point)
        Return either 0, 2*PI or -2*PI, depending whether the point is located inside the interior of the ellipse or not.
        Specified by:
        windingAngle in interface OrientedCurve2D
        Parameters:
        point - a point of the plane
        Returns:
        a signed angle
      • isInside

        public boolean isInside(Point2D point)
        Test whether the point is inside the ellipse. The test is performed by rotating the ellipse and the point to align with axis, rescaling in each direction, then computing distance to origin.
        Specified by:
        isInside in interface Boundary2D
        Specified by:
        isInside in interface OrientedCurve2D
        Parameters:
        point - a point in the plane
        Returns:
        true if the point is on the left side of the curve.
      • signedDistance

        public double signedDistance(Point2D point)
        Returns an approximation of the signed distance to the ellipse. In the current implementation, the ellipse is converted to a polyline.
        Specified by:
        signedDistance in interface OrientedCurve2D
        Parameters:
        point - a point of the plane
        Returns:
        the signed distance to the curve
      • signedDistance

        public double signedDistance(double x,                    double y)
        Description copied from interface: OrientedCurve2D
        The same as distanceSigned(Point2D), but by passing 2 double as arguments.
        Specified by:
        signedDistance in interface OrientedCurve2D
        Parameters:
        x - x-coord of a point
        y - y-coord of a point
        Returns:
        the signed distance of the point (x,y) to the curve
      • curvature

        public double curvature(double t)
        Returns the curvature of the ellipse.
        Specified by:
        curvature in interface ContinuousCurve2D
        Parameters:
        t - the position on the curve
        Returns:
        the curvature of the curve for position t
      • isClosed

        public boolean isClosed()
        Returns true, as an ellipse is always closed.
        Specified by:
        isClosed in interface ContinuousCurve2D
      • isBounded

        public boolean isBounded()
        Always returns true.
        Specified by:
        isBounded in interface Shape2D
      • isEmpty

        public boolean isEmpty()
        Always returns false.
        Specified by:
        isEmpty in interface Shape2D
        Returns:
        true if the shape does not contain any point.
      • t0

        public double t0()
        Returns the parameter of the first point of the ellipse, set to 0.
        Specified by:
        t0 in interface Curve2D
      • getT0

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

        public double t1()
        Returns the parameter of the last point of the ellipse, set to 2*PI.
        Specified by:
        t1 in interface Curve2D
      • getT1

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

        public Point2D point(double t)
        get the position of the curve from internal parametric representation, depending on the parameter t. This parameter is between the two limits 0 and 2*PI.
        Specified by:
        point in interface Curve2D
      • 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)
        Computes the approximate projection position of the point on the ellipse. The ellipse is first converted to a unit circle, then the angular position of the point is computed in the transformed basis.
        Specified by:
        project in interface Curve2D
        Parameters:
        point - a point to project
        Returns:
        the position of the closest orthogonal projection
      • distance

        public double distance(Point2D point)
        Computes distance using a polyline approximation.
        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
      • boundingBox

        public Box2D boundingBox()
        Return more precise bounds for the ellipse. Return an instance of Box2D.
        Specified by:
        boundingBox in interface Shape2D
        Returns:
        the bounding box of the shape.
      • intersections

        public Collection<Point2D> intersections(LinearShape2D line)
        Compute intersections of the ellipse with a straight object (line, line segment, ray...).

        Principle of the algorithm is to transform line and ellipse such that ellipse becomes a circle, then using the intersections computation from circle.

        Specified by:
        intersections in interface Curve2D
      • contains

        public boolean contains(Point2D p)
        Returns true if the point p lies on the ellipse, with precision given by Shape2D.ACCURACY.
        Specified by:
        contains in interface Shape2D
      • contains

        public boolean contains(double x,               double y)
        Returns true if the point (x, y) lies on the ellipse, with precision given by Shape2D.ACCURACY.
        Specified by:
        contains in interface Shape2D
      • 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

SCaVis 2.2 © jWork.ORG