Ellipse2D
math.geom2d.conic

## Class Ellipse2D

• ### Nested classes/interfaces inherited from interface math.geom2d.conic.Conic2D

`Conic2D.Type`

• ### Fields inherited from interface math.geom2d.Shape2D

`ACCURACY`
• ### Constructor Summary

Constructors
Constructor and Description
`Ellipse2D()`
Empty constructor, define ellipse centered at origin with both major and minor semi-axis with length equal to 1.
`Ellipse2D(double xc, double yc, double l1, double l2)`
Define center by coordinate, plus major and minor semi axis
`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(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(Ellipse2D ellipse)`
construct an ellipse from the java.awt.geom class for ellipse.
`Ellipse2D(Point2D center, double l1, double l2)`
Main constructor: define center by a point plus major and minor semi axis
`Ellipse2D(Point2D center, double l1, double l2, double theta)`
Define center by point, major and minor semi axis lengths, and orientation angle.
• ### Method Summary

Methods
Modifier and TypeMethod and Description
`boolean``almostEquals(GeometricObject2D obj, double eps)`
Checks if the two objects are similar up to a given threshold value.
`double``angle()`
Returns the angle of the ellipse first axis with the Ox axis.
`GeneralPath``appendPath(GeneralPath path)`
Add the path of the ellipse to the given path.
`LinearRing2D``asPolyline(int n)`
Converts this continuous curve to an instance of LinearCurve2D with the given number of edges.
`Box2D``boundingBox()`
Return more precise bounds for the ellipse.
`Point2D``center()`
Returns center of the ellipse.
`CurveSet2D<? extends SmoothOrientedCurve2D>``clip(Box2D box)`
Clip the ellipse by a box.
`Ellipse2D``clone()`
Deprecated.
`double[]``conicCoefficients()`
Returns the conic coefficients of the ellipse.
`Conic2D.Type``conicType()`
`boolean``contains(double x, double y)`
Returns true if the point (x, y) lies on the ellipse, with precision given by Shape2D.ACCURACY.
`boolean``contains(Point2D p)`
Returns true if the point p lies on the ellipse, with precision given by Shape2D.ACCURACY.
`Collection<? extends Ellipse2D>``continuousCurves()`
Returns the collection of continuous curves which constitute this curve.
`static Ellipse2D``create(Ellipse2D ellipse)`
Deprecated.
since 0.11.1
`static Ellipse2D``create(Point2D center, double l1, double l2)`
Deprecated.
since 0.11.1
`static Ellipse2D``create(Point2D center, double l1, double l2, double theta)`
Deprecated.
since 0.11.1
`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.
`static Ellipse2D``create(Point2D focus1, Point2D focus2, double chord)`
Create a new Ellipse by specifying the two focii, and the length of the chord.
`double``curvature(double t)`
Returns the curvature of the ellipse.
`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 point)`
Computes distance using a polyline approximation.
`Domain2D``domain()`
Returns the domain delimited by this boundary.
`void``draw(Graphics2D g2)`
Draws the curve on the given Graphics2D object.
`double``eccentricity()`
Computes eccentricity of ellipse, depending on the lengths of the semi-axes.
`boolean``equals(Object obj)`
`void``fill(Graphics2D g2)`
Fills the interior of the boundary, using the Graphics current Paint.
`Point2D``firstPoint()`
Returns the first point of the ellipse, which is the same as the last point.
`Point2D``focus1()`
Return the first focus.
`Point2D``focus2()`
Returns the second focus.
`GeneralPath``getGeneralPath()`
`double``getRho(double angle)`
Return the RHO parameter, in a polar representation of the ellipse, centered at the center of ellipse.
`double``getT0()`
Deprecated.
replaced by t0() (since 0.11.1).
`double``getT1()`
Deprecated.
replaced by t1() (since 0.11.1).
`static Ellipse2D``inertiaEllipse(Collection<Point2D> points)`
`Collection<Point2D>``intersections(LinearShape2D line)`
Compute intersections of the ellipse with a straight object (line, line segment, ray...).
`boolean``isBounded()`
Always returns true.
`boolean``isCircle()`
Returns true if this ellipse is similar to a circle, i.e.
`boolean``isClosed()`
Returns true, as an ellipse is always closed.
`boolean``isDirect()`
Returns true if ellipse has a direct orientation.
`boolean``isEmpty()`
Always returns false.
`boolean``isInside(Point2D point)`
Test whether the point is inside the ellipse.
`Point2D``lastPoint()`
Returns the last point of the ellipse, which is the same as the first point.
`Ellipse2D``parallel(double d)`
Return the parallel ellipse located at a distance d from this ellipse.
`Point2D``point(double t)`
get the position of the curve from internal parametric representation, depending on the parameter t.
`double``position(Point2D point)`
Computes the position of the point on the curve.
`double``project(Point2D point)`
Computes the approximate projection position of the point on the ellipse.
`Point2D``projectedPoint(Point2D point)`
`Vector2D``projectedVector(Point2D point, double eMax)`
Compute projection of a point onto an ellipse.
`static Ellipse2D``reduceCentered(double[] coefs)`
Creates a new Ellipse by reducing the conic coefficients, assuming conic type is ellipse, and ellipse is centered.
`Ellipse2D``reverse()`
Returns the ellipse with same center and same radius, but with the other orientation.
`double``semiMajorAxisLength()`
Returns the length of the major semi-axis of the ellipse.
`double``semiMinorAxisLength()`
Returns the length of the minor semi-axis of the ellipse.
`double``signedDistance(double x, double y)`
The same as distanceSigned(Point2D), but by passing 2 double as arguments.
`double``signedDistance(Point2D point)`
Returns an approximation of the signed distance to the ellipse.
`EllipseArc2D``subCurve(double t0, double t1)`
return a new EllipseArc2D.
`double``t0()`
Returns the parameter of the first point of the ellipse, set to 0.
`double``t1()`
Returns the parameter of the last point of the ellipse, set to 2*PI.
`Vector2D``tangent(double t)`
Returns the tangent of the curve at the given position.
`String``toString()`
`Ellipse2D``transform(AffineTransform2D trans)`
Transforms this ellipse by an affine transform.
`static Ellipse2D``transformCentered(Ellipse2D ellipse, AffineTransform2D trans)`
Transform an ellipse, by supposing both the ellipse is centered and the transform has no translation part.
`Vector2D``vector1()`
Returns the first direction vector of the ellipse, in the direction of the major axis.
`Vector2D``vector2()`
Returns the second direction vector of the ellipse, in the direction of the minor axis.
`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.
• ### Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D

`isSingular, leftTangent, normal, rightTangent, singularPoints, smoothPieces, vertices`
• ### Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D

`asAwtShape`
• ### Methods inherited from class java.lang.Object

`getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface math.geom2d.curve.SmoothCurve2D

`normal`
• ### Methods inherited from interface math.geom2d.curve.ContinuousCurve2D

`leftTangent, rightTangent, smoothPieces`
• ### Methods inherited from interface math.geom2d.curve.Curve2D

`asAwtShape, isSingular, singularPoints, vertices`
• ### 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
• #### inertiaEllipse

`public static final Ellipse2D inertiaEllipse(Collection<Point2D> points)`
• #### 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
• #### projectedPoint

`public Point2D projectedPoint(Point2D point)`
• #### 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`
`parallelpublic 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 insideisDirectpublic boolean isDirect()Returns true if ellipse has a direct orientation.Specified by:isDirect in interface EllipseShape2DisCirclepublic 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 EllipseShape2DsemiMajorAxisLengthpublic double semiMajorAxisLength()Returns the length of the major semi-axis of the ellipse.semiMinorAxisLengthpublic double semiMinorAxisLength()Returns the length of the minor semi-axis of the ellipse.centerpublic Point2D center()Returns center of the ellipse.Specified by:center in interface EllipseShape2Dfocus1public Point2D focus1()Return the first focus. It is defined as the first focus on the Major axis, in the direction given by angle theta.focus2public Point2D focus2()Returns the second focus. It is defined as the second focus on the Major axis, in the direction given by angle theta.vector1public Vector2D vector1()Returns the first direction vector of the ellipse, in the direction of the major axis.vector2public Vector2D vector2()Returns the second direction vector of the ellipse, in the direction of the minor axis.anglepublic double angle()Returns the angle of the ellipse first axis with the Ox axis.conicTypepublic Conic2D.Type conicType()Specified by:conicType in interface Conic2DconicCoefficientspublic double[] conicCoefficients()Returns the conic coefficients of the ellipse. Algorithm taken from http://tog.acm.org/GraphicsGems/gemsv/ch2-6/conmat.cSpecified by:conicCoefficients in interface Conic2Deccentricitypublic 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 Conic2Ddomainpublic Domain2D domain()Description copied from interface: Boundary2DReturns the domain delimited by this boundary.Specified by:domain in interface Boundary2DReturns:the domain delimited by this boundaryfillpublic void fill(Graphics2D g2)Description copied from interface: Boundary2DFills the interior of the boundary, using the Graphics current Paint.Specified by:fill in interface Boundary2DParameters:g2 - the Graphics to fill onwindingAnglepublic 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 OrientedCurve2DParameters:point - a point of the planeReturns:a signed angleisInsidepublic 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 Boundary2DSpecified by:isInside in interface OrientedCurve2DParameters:point - a point in the planeReturns:true if the point is on the left side of the curve.signedDistancepublic 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 OrientedCurve2DParameters:point - a point of the planeReturns:the signed distance to the curvesignedDistancepublic double signedDistance(double x, double y)Description copied from interface: OrientedCurve2DThe same as distanceSigned(Point2D), but by passing 2 double as arguments.Specified by:signedDistance in interface OrientedCurve2DParameters:x - x-coord of a pointy - y-coord of a pointReturns:the signed distance of the point (x,y) to the curvetangentpublic Vector2D tangent(double t)Description copied from interface: SmoothCurve2DReturns the tangent of the curve at the given position.Specified by:tangent in interface SmoothCurve2DParameters:t - a position on the curveReturns:the tangent vector computed for position tSee Also:SmoothCurve2D.normal(double)curvaturepublic double curvature(double t)Returns the curvature of the ellipse.Specified by:curvature in interface ContinuousCurve2DParameters:t - the position on the curveReturns:the curvature of the curve for position tisClosedpublic boolean isClosed()Returns true, as an ellipse is always closed.Specified by:isClosed in interface ContinuousCurve2DasPolylinepublic LinearRing2D asPolyline(int n)Description copied from class: AbstractContinuousCurve2DConverts this continuous curve to an instance of LinearCurve2D with the given number of edges. Returns either an instance of Polyline2D or LinearRing2D, depending on the curve is closed or not. This method can be overridden to return the correct type.Specified by:asPolyline in interface ContinuousCurve2DOverrides:asPolyline in class AbstractContinuousCurve2DParameters:n - the number of line segmentsReturns:a polyline with n line segments.See Also:ContinuousCurve2D.asPolyline(int)isBoundedpublic boolean isBounded()Always returns true.Specified by:isBounded in interface Shape2DisEmptypublic boolean isEmpty()Always returns false.Specified by:isEmpty in interface Shape2DReturns:true if the shape does not contain any point.t0public double t0()Returns the parameter of the first point of the ellipse, set to 0.Specified by:t0 in interface Curve2DgetT0@Deprecatedpublic double getT0()Deprecated. replaced by t0() (since 0.11.1).Specified by:getT0 in interface Curve2Dt1public double t1()Returns the parameter of the last point of the ellipse, set to 2*PI.Specified by:t1 in interface Curve2DgetT1@Deprecatedpublic double getT1()Deprecated. replaced by t1() (since 0.11.1).Specified by:getT1 in interface Curve2Dpointpublic 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 Curve2DfirstPointpublic Point2D firstPoint()Returns the first point of the ellipse, which is the same as the last point.Specified by:firstPoint in interface Curve2DOverrides:firstPoint in class AbstractContinuousCurve2DReturns:the first point of the ellipseSee Also:Curve2D.t0(), Curve2D.point(double)lastPointpublic Point2D lastPoint()Returns the last point of the ellipse, which is the same as the first point.Specified by:lastPoint in interface Curve2DOverrides:lastPoint in class AbstractContinuousCurve2DReturns:the last point of the ellipse.See Also:Curve2D.t1(), Curve2D.point(double)positionpublic double position(Point2D point)Description copied from interface: Curve2DComputes 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 Curve2DParameters:point - a point belonging to the curveReturns:the position of the point on the curveSee Also:Curve2D.point(double)projectpublic 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 Curve2DParameters:point - a point to projectReturns:the position of the closest orthogonal projectionreversepublic Ellipse2D reverse()Returns the ellipse with same center and same radius, but with the other orientation.Specified by:reverse in interface Conic2DSpecified by:reverse in interface EllipseShape2DSpecified by:reverse in interface ContinuousCurve2DSpecified by:reverse in interface Curve2DSpecified by:reverse in interface SmoothCurve2DSpecified by:reverse in interface Boundary2DSpecified by:reverse in interface ContinuousOrientedCurve2DSpecified by:reverse in interface Contour2DSpecified by:reverse in interface OrientedCurve2DSpecified by:reverse in interface SmoothContour2DSpecified by:reverse in interface SmoothOrientedCurve2DcontinuousCurvespublic Collection<? extends Ellipse2D> continuousCurves()Description copied from interface: Curve2DReturns the collection of continuous curves which constitute this curve.Specified by:continuousCurves in interface EllipseShape2DSpecified by:continuousCurves in interface Curve2DSpecified by:continuousCurves in interface Boundary2DOverrides:continuousCurves in class AbstractContinuousCurve2DReturns:a collection of continuous curves.subCurvepublic EllipseArc2D subCurve(double t0, double t1)return a new EllipseArc2D.Specified by:subCurve in interface ContinuousCurve2DSpecified by:subCurve in interface Curve2DSpecified by:subCurve in interface SmoothCurve2DSpecified by:subCurve in interface ContinuousOrientedCurve2DSpecified by:subCurve in interface SmoothOrientedCurve2DParameters:t0 - position of the start of the sub-curvet1 - position of the end of the sub-curveReturns:the portion of original curve comprised between t0 and t1.distancepublic double distance(Point2D point)Computes distance using a polyline approximation.Specified by:distance in interface Shape2Ddistancepublic double distance(double x, double y)Description copied from interface: Shape2DReturns 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 Shape2Dclippublic CurveSet2D<? extends SmoothOrientedCurve2D> clip(Box2D box)Clip the ellipse by a box. The result is an instance of CurveSet2D, which contains only instances of Ellipse2D or EllipseArc2D. If the ellipse is not clipped, the result is an instance of CurveSet2D which contains 0 curves.Specified by:clip in interface Conic2DSpecified by:clip in interface ContinuousCurve2DSpecified by:clip in interface Curve2DSpecified by:clip in interface SmoothCurve2DSpecified by:clip in interface ContinuousOrientedCurve2DSpecified by:clip in interface OrientedCurve2DSpecified by:clip in interface SmoothOrientedCurve2DSpecified by:clip in interface Shape2DParameters:box - the clipping boxReturns:the clipped shapeboundingBoxpublic Box2D boundingBox()Return more precise bounds for the ellipse. Return an instance of Box2D.Specified by:boundingBox in interface Shape2DReturns:the bounding box of the shape.intersectionspublic 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 Curve2Dtransformpublic Ellipse2D transform(AffineTransform2D trans)Transforms this ellipse by an affine transform. If the transformed shape is a circle (ellipse with equal axis lengths), returns an instance of Circle2D. The resulting ellipse is direct if this ellipse and the transform are either both direct or both indirect.Specified by:transform in interface Conic2DSpecified by:transform in interface EllipseShape2DSpecified by:transform in interface ContinuousCurve2DSpecified by:transform in interface Curve2DSpecified by:transform in interface SmoothCurve2DSpecified by:transform in interface Boundary2DSpecified by:transform in interface ContinuousOrientedCurve2DSpecified by:transform in interface Contour2DSpecified by:transform in interface OrientedCurve2DSpecified by:transform in interface SmoothContour2DSpecified by:transform in interface SmoothOrientedCurve2DSpecified by:transform in interface Shape2DParameters:trans - an affine transformReturns:the transformed shapecontainspublic 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 Shape2Dcontainspublic 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 Shape2DgetGeneralPathpublic GeneralPath getGeneralPath()appendPathpublic GeneralPath appendPath(GeneralPath path)Add the path of the ellipse to the given path.Specified by:appendPath in interface ContinuousCurve2DParameters:path - the path to be completedReturns:the completed pathdrawpublic void draw(Graphics2D g2)Description copied from interface: Curve2DDraws the curve on the given Graphics2D object.Specified by:draw in interface Curve2DSpecified by:draw in interface Shape2DOverrides:draw in class AbstractContinuousCurve2DParameters:g2 - the graphics to draw the curve inalmostEqualspublic boolean almostEquals(GeometricObject2D obj, double eps)Description copied from interface: GeometricObject2DChecks 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 GeometricObject2DParameters:obj - the object to compareeps - a threshold value, for example the minimal coordinate differenceReturns:true if both object have the same value up to the thresholdequalspublic boolean equals(Object obj)Overrides:equals in class Objectclone@Deprecatedpublic Ellipse2D clone()Deprecated. use copy constructor instead (0.11.2)Specified by:clone in interface Curve2DSpecified by:clone in class AbstractSmoothCurve2DtoStringpublic String toString()Overrides:toString in class Object`
`OverviewPackageClassTreeIndexHelp`

`SCaVis 2.2 © jWork.ORG`

``` ```
``` © 2013 Powered by Doc2SQL Page generated in 0.0053701400756836 seconds and 525 kB ```