public class Ellipse2D extends AbstractSmoothCurve2D implements SmoothBoundary2D, Conic2D, Cloneable
Conic2D.Type
Modifier and Type | Field and Description |
---|---|
protected boolean |
direct
directed ellipse or not
|
protected double |
r1
length of major semi-axis
|
protected double |
r2
length of minor semi-axis
|
protected double |
theta
orientation of major semi-axis
|
protected double |
xc
coordinate of center.
|
protected double |
yc |
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.
|
Modifier and Type | Method and Description |
---|---|
GeneralPath |
appendPath(GeneralPath path)
Add the path of the ellipse to the given path.
|
CurveSet2D<? extends SmoothOrientedCurve2D> |
clip(Box2D box)
Clip the ellipse by a box.
|
Ellipse2D |
clone()
Overrides Object declaration to ensure Curve2D implementation are
cloned as Curve2D.
|
boolean |
contains(double x,
double y)
Return true if the point (x, y) lies on the ellipse, with precision given
by Shape2D.ACCURACY.
|
boolean |
contains(Point2D p)
Return true if the point p lies on the ellipse, with precision given by
Shape2D.ACCURACY.
|
static Ellipse2D |
create(Ellipse2D ellipse)
Constructs an ellipse from the java.awt.geom class for ellipse.
|
static Ellipse2D |
create(Point2D center,
double l1,
double l2)
Main constructor: define center by a point plus major and minor semi axis
|
static Ellipse2D |
create(Point2D center,
double l1,
double l2,
double theta)
Define center by point, major and minor semi axis lengths, and
orientation angle.
|
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.
|
void |
draw(Graphics2D g2)
Draws the curve on the given Graphics2D object.
|
boolean |
equals(Object obj) |
void |
fill(Graphics2D g2) |
double |
getAngle()
return the angle of the ellipse first axis with the Ox axis.
|
Collection<? extends Ellipse2D> |
getBoundaryCurves()
Returns the different continuous curves composing the boundary
|
Box2D |
getBoundingBox()
Return more precise bounds for the ellipse.
|
Point2D |
getCenter()
Returns center of the ellipse.
|
double[] |
getConicCoefficients()
Returns the conic coefficients of the ellipse.
|
Conic2D.Type |
getConicType() |
Collection<? extends Ellipse2D> |
getContinuousCurves()
Returns the collection of continuous curves which constitute this curve.
|
double |
getCurvature(double t)
Returns the curvature of the ellipse.
|
double |
getDistance(double x,
double y)
get 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 |
getDistance(Point2D point)
get 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.
|
Domain2D |
getDomain()
Returns the domain delimited by this boundary.
|
double |
getEccentricity()
Computes eccentricity of ellipse, depending on the lengths of the
semi-axes.
|
Point2D |
getFirstPoint()
Get the first point of the ellipse, which is the same as the last point.
|
Point2D |
getFocus1()
Return the first focus.
|
Point2D |
getFocus2()
Returns the second focus.
|
GeneralPath |
getGeneralPath() |
Collection<Point2D> |
getIntersections(LinearShape2D line)
Compute intersections of the ellipse with a straight object (line, line
segment, ray...).
|
Point2D |
getLastPoint()
Get the last point of the ellipse, which is the same as the first point.
|
Ellipse2D |
getParallel(double d)
Return the parallel ellipse located at a distance d from this ellipse.
|
Point2D |
getPoint(double t)
get the position of the curve from internal parametric representation,
depending on the parameter t.
|
double |
getPosition(Point2D point)
Get position of the point on the curve.
|
Point2D |
getProjectedPoint(Point2D point) |
Vector2D |
getProjectedVector(Point2D point,
double eMax)
Compute projection of a point onto an ellipse.
|
Ellipse2D |
getReverseCurve()
Returns the ellipse with same center and same radius, but with the other
orientation.
|
double |
getRho(double angle)
Return the RHO parameter, in a polar representation of the ellipse,
centered at the center of ellipse.
|
double |
getSemiMajorAxisLength()
Returns the length of the major semi-axis of the ellipse.
|
double |
getSemiMinorAxisLength()
Returns the length of the minor semi-axis of the ellipse.
|
double |
getSignedDistance(double x,
double y)
The same as getSignedDistance(Point2D), but by passing 2 double as
arguments.
|
double |
getSignedDistance(Point2D point)
Get the signed distance of the curve to the given point: this distance is
positive if the point lies outside the shape, and is negative if the
point lies inside the shape.
|
EllipseArc2D |
getSubCurve(double t0,
double t1)
return a new EllipseArc2D.
|
double |
getT0()
Returns the parameter of the first point of the ellipse, set to 0.
|
double |
getT1()
Returns the parameter of the last point of the ellipse, set to 2*PI.
|
Vector2D |
getTangent(double t) |
Vector2D |
getVector1() |
Vector2D |
getVector2() |
double |
getWindingAngle(Point2D point)
Return either 0, 2*PI or -2*PI, depending whether the point is located
inside the interior of the ellipse or not.
|
boolean |
isBounded()
Always returns true, because an ellipse is bounded.
|
boolean |
isCircle() |
boolean |
isClosed()
Returns true, as an ellipse is always closed.
|
boolean |
isDirect()
return true if ellipse has a direct orientation.
|
boolean |
isEmpty()
Returns true if the shape does not contain any point.
|
boolean |
isInside(Point2D point)
Test whether the point is inside the ellipse.
|
double |
project(Point2D point)
Computes the approximate projection position of the point on the ellipse.
|
static Ellipse2D |
reduceCentered(double[] coefs)
Creates a new Ellipse by reducing the conic coefficients, assuming conic
type is ellipse, and ellipse is centered.
|
void |
setCenter(double x,
double y)
Deprecated.
conics will become immutable in a future release
|
void |
setCenter(Point2D center)
Deprecated.
conics will become immutable in a future release
|
void |
setEllipse(double xc,
double yc,
double r1,
double r2,
double theta)
Deprecated.
conics will become immutable in a future release
|
void |
setEllipse(double xc,
double yc,
double r1,
double r2,
double theta,
boolean direct)
Deprecated.
conics will become immutable in a future release
|
void |
setEllipse(Point2D center,
double r1,
double r2,
double theta)
Deprecated.
conics will become immutable in a future release
|
void |
setEllipse(Point2D center,
double r1,
double r2,
double theta,
boolean direct)
Deprecated.
conics will become immutable in a future release
|
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.
|
getLeftTangent, getRightTangent, getSingularPoints, getSmoothPieces, isSingular
getAsAWTShape, getAsPolyline, wrapCurve
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAsPolyline, getLeftTangent, getRightTangent, getSmoothPieces
getAsAWTShape, getSingularPoints, isSingular
protected double xc
protected double yc
protected double r1
protected double r2
protected double theta
protected boolean direct
public Ellipse2D()
public Ellipse2D(Point2D center, double l1, double l2)
public Ellipse2D(double xc, double yc, double l1, double l2)
public Ellipse2D(Point2D center, double l1, double l2, double theta)
public Ellipse2D(double xc, double yc, double l1, double l2, double theta)
public Ellipse2D(double xc, double yc, double l1, double l2, double theta, boolean direct)
public Ellipse2D(Ellipse2D ellipse)
public static Ellipse2D create(Point2D focus1, Point2D focus2, double chord)
focus1
- the first focusfocus2
- the second focuschord
- the sum of distances to fociipublic static Ellipse2D create(Point2D center, double l1, double l2)
public static Ellipse2D create(Point2D center, double l1, double l2, double theta)
public static Ellipse2D create(Point2D center, double l1, double l2, double theta, boolean direct)
public static Ellipse2D create(Ellipse2D ellipse)
public static final Ellipse2D reduceCentered(double[] coefs)
coefs
- an array of double with at least 3 coefficients containing
coefficients for x^2, xy, and y^2 factors.public static final Ellipse2D transformCentered(Ellipse2D ellipse, AffineTransform2D trans)
ellipse
- an ellipsetrans
- an affine transform@Deprecated public void setEllipse(double xc, double yc, double r1, double r2, double theta)
@Deprecated public void setEllipse(double xc, double yc, double r1, double r2, double theta, boolean direct)
@Deprecated public void setEllipse(Point2D center, double r1, double r2, double theta)
@Deprecated public void setEllipse(Point2D center, double r1, double r2, double theta, boolean direct)
@Deprecated public void setCenter(Point2D center)
@Deprecated public void setCenter(double x, double y)
public double getRho(double angle)
angle
- : angle from horizontalpublic Vector2D getProjectedVector(Point2D point, double eMax)
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
point
- eMax
- public Ellipse2D getParallel(double d)
public boolean isDirect()
public boolean isCircle()
public Conic2D.Type getConicType()
getConicType
in interface Conic2D
public double[] getConicCoefficients()
getConicCoefficients
in interface Conic2D
public double getSemiMajorAxisLength()
public double getSemiMinorAxisLength()
public double getEccentricity()
getEccentricity
in interface Conic2D
public Point2D getCenter()
public Point2D getFocus1()
public Point2D getFocus2()
public Vector2D getVector1()
public Vector2D getVector2()
public double getAngle()
public Collection<? extends Ellipse2D> getBoundaryCurves()
Boundary2D
getBoundaryCurves
in interface Boundary2D
public Domain2D getDomain()
Boundary2D
getDomain
in interface Boundary2D
public void fill(Graphics2D g2)
fill
in interface Boundary2D
public double getWindingAngle(Point2D point)
getWindingAngle
in interface OrientedCurve2D
point
- a point of the planepublic boolean isInside(Point2D point)
isInside
in interface Boundary2D
isInside
in interface OrientedCurve2D
point
- a point in the planepublic double getSignedDistance(Point2D point)
OrientedCurve2D
getSignedDistance
in interface OrientedCurve2D
point
- a point of the planepublic double getSignedDistance(double x, double y)
OrientedCurve2D
getSignedDistance
in interface OrientedCurve2D
x
- x-coord of a pointy
- y-coord of a pointpublic Vector2D getTangent(double t)
getTangent
in interface SmoothCurve2D
public double getCurvature(double t)
getCurvature
in interface SmoothCurve2D
public boolean isClosed()
isClosed
in interface ContinuousCurve2D
public double getT0()
public double getT1()
public Point2D getPoint(double t)
public Point2D getFirstPoint()
getFirstPoint
in interface Curve2D
getFirstPoint
in class AbstractContinuousCurve2D
public Point2D getLastPoint()
getLastPoint
in interface Curve2D
getLastPoint
in class AbstractContinuousCurve2D
public double getPosition(Point2D point)
Curve2D
getPosition
in interface Curve2D
point
- a point belonging to the curvepublic double project(Point2D point)
public Ellipse2D getReverseCurve()
getReverseCurve
in interface Conic2D
getReverseCurve
in interface ContinuousCurve2D
getReverseCurve
in interface Curve2D
getReverseCurve
in interface SmoothCurve2D
getReverseCurve
in interface Boundary2D
getReverseCurve
in interface ContinuousBoundary2D
getReverseCurve
in interface ContinuousOrientedCurve2D
getReverseCurve
in interface OrientedCurve2D
getReverseCurve
in interface SmoothBoundary2D
getReverseCurve
in interface SmoothOrientedCurve2D
public Collection<? extends Ellipse2D> getContinuousCurves()
Curve2D
getContinuousCurves
in interface Curve2D
getContinuousCurves
in class AbstractContinuousCurve2D
public EllipseArc2D getSubCurve(double t0, double t1)
getSubCurve
in interface ContinuousCurve2D
getSubCurve
in interface Curve2D
getSubCurve
in interface SmoothCurve2D
getSubCurve
in interface ContinuousOrientedCurve2D
getSubCurve
in interface SmoothOrientedCurve2D
t0
- position of the start of the sub-curvet1
- position of the end of the sub-curvepublic boolean isBounded()
public boolean isEmpty()
Shape2D
public double getDistance(Point2D point)
Shape2D
getDistance
in interface Shape2D
public double getDistance(double x, double y)
Shape2D
getDistance
in interface Shape2D
public CurveSet2D<? extends SmoothOrientedCurve2D> clip(Box2D box)
clip
in interface Conic2D
clip
in interface ContinuousCurve2D
clip
in interface Curve2D
clip
in interface SmoothCurve2D
clip
in interface ContinuousOrientedCurve2D
clip
in interface OrientedCurve2D
clip
in interface SmoothOrientedCurve2D
clip
in interface Shape2D
box
- the clipping boxpublic Box2D getBoundingBox()
getBoundingBox
in interface Shape2D
public Collection<Point2D> getIntersections(LinearShape2D line)
Principle of the algorithm is to transform line and ellipse such that ellipse becomes a circle, then using the intersections computation from circle.
getIntersections
in interface Curve2D
public Ellipse2D transform(AffineTransform2D trans)
transform
in interface Conic2D
transform
in interface ContinuousCurve2D
transform
in interface Curve2D
transform
in interface SmoothCurve2D
transform
in interface Boundary2D
transform
in interface ContinuousBoundary2D
transform
in interface ContinuousOrientedCurve2D
transform
in interface OrientedCurve2D
transform
in interface SmoothBoundary2D
transform
in interface SmoothOrientedCurve2D
transform
in interface Shape2D
trans
- an affine transformpublic boolean contains(Point2D p)
public boolean contains(double x, double y)
public GeneralPath getGeneralPath()
public GeneralPath appendPath(GeneralPath path)
appendPath
in interface ContinuousCurve2D
path
- the path to be completedpublic void draw(Graphics2D g2)
Curve2D
public Ellipse2D clone()
Curve2D
clone
in interface Curve2D
clone
in class AbstractSmoothCurve2D
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.