|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmath.geom2d.curve.AbstractContinuousCurve2D
math.geom2d.curve.AbstractSmoothCurve2D
math.geom2d.conic.Ellipse2D
public class Ellipse2D
An ellipse in the plane. It is defined by the center, the orientation angle, and the lengths of the two axis. No convention is taken about lengths of semiaxis : the second semi axis can be greater than the first one.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface math.geom2d.conic.Conic2D |
---|
Conic2D.Type |
Field Summary | |
---|---|
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
|
Fields inherited from interface math.geom2d.Shape2D |
---|
ACCURACY |
Constructor Summary | |
---|---|
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 | |
---|---|
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. |
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D |
---|
getLeftTangent, getRightTangent, getSingularPoints, getSmoothPieces, isSingular |
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D |
---|
getAsAWTShape, getAsPolyline, wrapCurve |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D |
---|
getAsPolyline, getLeftTangent, getRightTangent, getSmoothPieces |
Methods inherited from interface math.geom2d.curve.Curve2D |
---|
getAsAWTShape, getSingularPoints, isSingular |
Field Detail |
---|
protected double xc
protected double yc
protected double r1
protected double r2
protected double theta
protected boolean direct
Constructor Detail |
---|
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)
Method Detail |
---|
public static Ellipse2D create(Point2D focus1, Point2D focus2, double chord)
focus1
- the first focusfocus2
- the second focuschord
- the sum of distances to focii
public 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 horizontal
public Point2D getProjectedPoint(Point2D point)
public 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
- Parameters:
point
- eMax
-
- Returns:
- the projection vector
getParallel
public Ellipse2D getParallel(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()
- return true if ellipse has a direct orientation.
isCircle
public boolean isCircle()
getConicType
public Conic2D.Type getConicType()
- Specified by:
getConicType
in interface Conic2D
getConicCoefficients
public double[] getConicCoefficients()
- Returns the conic coefficients of the ellipse. Algorithm taken from
http://tog.acm.org/GraphicsGems/gemsv/ch2-6/conmat.c
- Specified by:
getConicCoefficients
in interface Conic2D
getSemiMajorAxisLength
public double getSemiMajorAxisLength()
- Returns the length of the major semi-axis of the ellipse.
getSemiMinorAxisLength
public double getSemiMinorAxisLength()
- Returns the length of the minor semi-axis of the ellipse.
getEccentricity
public double getEccentricity()
- 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:
getEccentricity
in interface Conic2D
getCenter
public Point2D getCenter()
- Returns center of the ellipse.
getFocus1
public Point2D getFocus1()
- Return the first focus. It is defined as the first focus on the Major
axis, in the direction given by angle theta.
getFocus2
public Point2D getFocus2()
- Returns the second focus. It is defined as the second focus on the Major
axis, in the direction given by angle theta.
getVector1
public Vector2D getVector1()
getVector2
public Vector2D getVector2()
getAngle
public double getAngle()
- return the angle of the ellipse first axis with the Ox axis.
getBoundaryCurves
public Collection<? extends Ellipse2D> getBoundaryCurves()
- Description copied from interface:
Boundary2D
- Returns the different continuous curves composing the boundary
- Specified by:
getBoundaryCurves
in interface Boundary2D
getDomain
public Domain2D getDomain()
- Description copied from interface:
Boundary2D
- Returns the domain delimited by this boundary.
- Specified by:
getDomain
in interface Boundary2D
- Returns:
- the domain delimited by this boundary
fill
public void fill(Graphics2D g2)
- Specified by:
fill
in interface Boundary2D
getWindingAngle
public 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.
- Specified by:
getWindingAngle
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.
getSignedDistance
public double getSignedDistance(Point2D point)
- Description copied from interface:
OrientedCurve2D
- 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. In this case, absolute value of distance is
equals to the distance to the border of the shape.
- Specified by:
getSignedDistance
in interface OrientedCurve2D
- Parameters:
point
- a point of the plane
- Returns:
- the signed distance to the curve
getSignedDistance
public double getSignedDistance(double x,
double y)
- Description copied from interface:
OrientedCurve2D
- The same as getSignedDistance(Point2D), but by passing 2 double as
arguments.
- Specified by:
getSignedDistance
in interface OrientedCurve2D
- Parameters:
x
- x-coord of a pointy
- y-coord of a point
- Returns:
- the signed distance of the point (x,y) to the curve
getTangent
public Vector2D getTangent(double t)
- Specified by:
getTangent
in interface SmoothCurve2D
getCurvature
public double getCurvature(double t)
- Returns the curvature of the ellipse.
- Specified by:
getCurvature
in interface SmoothCurve2D
isClosed
public boolean isClosed()
- Returns true, as an ellipse is always closed.
- Specified by:
isClosed
in interface ContinuousCurve2D
getT0
public double getT0()
- Returns the parameter of the first point of the ellipse, set to 0.
- Specified by:
getT0
in interface Curve2D
getT1
public double getT1()
- Returns the parameter of the last point of the ellipse, set to 2*PI.
- Specified by:
getT1
in interface Curve2D
getPoint
public Point2D getPoint(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*Math.PI.
- Specified by:
getPoint
in interface Curve2D
getFirstPoint
public Point2D getFirstPoint()
- Get the first point of the ellipse, which is the same as the last point.
- Specified by:
getFirstPoint
in interface Curve2D
- Overrides:
getFirstPoint
in class AbstractContinuousCurve2D
- Returns:
- the first point of the curve
getLastPoint
public Point2D getLastPoint()
- Get the last point of the ellipse, which is the same as the first point.
- Specified by:
getLastPoint
in interface Curve2D
- Overrides:
getLastPoint
in class AbstractContinuousCurve2D
- Returns:
- the last point of the curve.
getPosition
public double getPosition(Point2D point)
- Description copied from interface:
Curve2D
- Get position of the point on the curve. If the point does not belong to
the curve, return Double.NaN.
- Specified by:
getPosition
in interface Curve2D
- Parameters:
point
- a point belonging to the curve
- Returns:
- the position of the point on the curve
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
getReverseCurve
public Ellipse2D getReverseCurve()
- Returns the ellipse with same center and same radius, but with the other
orientation.
- Specified by:
getReverseCurve
in interface Conic2D
- Specified by:
getReverseCurve
in interface ContinuousCurve2D
- Specified by:
getReverseCurve
in interface Curve2D
- Specified by:
getReverseCurve
in interface SmoothCurve2D
- Specified by:
getReverseCurve
in interface Boundary2D
- Specified by:
getReverseCurve
in interface ContinuousBoundary2D
- Specified by:
getReverseCurve
in interface ContinuousOrientedCurve2D
- Specified by:
getReverseCurve
in interface OrientedCurve2D
- Specified by:
getReverseCurve
in interface SmoothBoundary2D
- Specified by:
getReverseCurve
in interface SmoothOrientedCurve2D
getContinuousCurves
public Collection<? extends Ellipse2D> getContinuousCurves()
- Description copied from interface:
Curve2D
- Returns the collection of continuous curves which constitute this curve.
- Specified by:
getContinuousCurves
in interface Curve2D
- Overrides:
getContinuousCurves
in class AbstractContinuousCurve2D
- Returns:
- a collection of continuous curves.
getSubCurve
public EllipseArc2D getSubCurve(double t0,
double t1)
- return a new EllipseArc2D.
- Specified by:
getSubCurve
in interface ContinuousCurve2D
- Specified by:
getSubCurve
in interface Curve2D
- Specified by:
getSubCurve
in interface SmoothCurve2D
- Specified by:
getSubCurve
in interface ContinuousOrientedCurve2D
- Specified by:
getSubCurve
in interface SmoothOrientedCurve2D
- Parameters:
t0
- position of the start of the sub-curvet1
- position of the end of the sub-curve
- Returns:
- the portion of original curve comprised between t0 and t1.
isBounded
public boolean isBounded()
- Always returns true, because an ellipse is bounded.
- Specified by:
isBounded
in interface Shape2D
isEmpty
public boolean isEmpty()
- Description copied from interface:
Shape2D
- Returns true if the shape does not contain any point. This is the case
for example for PointSet2D without any point.
- Specified by:
isEmpty
in interface Shape2D
- Returns:
- true if the shape does not contain any point.
getDistance
public double getDistance(Point2D point)
- Description copied from interface:
Shape2D
- 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.
- Specified by:
getDistance
in interface Shape2D
getDistance
public double getDistance(double x,
double y)
- Description copied from interface:
Shape2D
- 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. fillable) shape.
- Specified by:
getDistance
in interface Shape2D
clip
public 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 Conic2D
- Specified by:
clip
in interface ContinuousCurve2D
- Specified by:
clip
in interface Curve2D
- Specified by:
clip
in interface SmoothCurve2D
- Specified by:
clip
in interface ContinuousOrientedCurve2D
- Specified by:
clip
in interface OrientedCurve2D
- Specified by:
clip
in interface SmoothOrientedCurve2D
- Specified by:
clip
in interface Shape2D
- Parameters:
box
- the clipping box
- Returns:
- the clipped shape
getBoundingBox
public Box2D getBoundingBox()
- Return more precise bounds for the ellipse. Return an instance of Box2D.
- Specified by:
getBoundingBox
in interface Shape2D
- Returns:
- the bounding box of the shape.
getIntersections
public Collection<Point2D> getIntersections(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:
getIntersections
in interface Curve2D
transform
public 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 Conic2D
- Specified by:
transform
in interface ContinuousCurve2D
- Specified by:
transform
in interface Curve2D
- Specified by:
transform
in interface SmoothCurve2D
- Specified by:
transform
in interface Boundary2D
- Specified by:
transform
in interface ContinuousBoundary2D
- Specified by:
transform
in interface ContinuousOrientedCurve2D
- Specified by:
transform
in interface OrientedCurve2D
- Specified by:
transform
in interface SmoothBoundary2D
- Specified by:
transform
in interface SmoothOrientedCurve2D
- Specified by:
transform
in interface Shape2D
- Parameters:
trans
- an affine transform
- Returns:
- the transformed shape
contains
public boolean contains(Point2D p)
- Return 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)
- Return true if the point (x, y) lies on the ellipse, with precision given
by Shape2D.ACCURACY.
- Specified by:
contains
in interface Shape2D
getGeneralPath
public GeneralPath getGeneralPath()
appendPath
public GeneralPath appendPath(GeneralPath path)
- Add the path of the ellipse to the given path.
- Specified by:
appendPath
in interface ContinuousCurve2D
- Parameters:
path
- the path to be completed
- Returns:
- the completed path
draw
public void draw(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
- Overrides:
draw
in class AbstractContinuousCurve2D
- Parameters:
g2
- the graphics to draw the curve
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
clone
public Ellipse2D clone()
- Description copied from interface:
Curve2D
- Overrides Object declaration to ensure Curve2D implementation are
cloned as Curve2D.
- Specified by:
clone
in interface Curve2D
- Specified by:
clone
in class AbstractSmoothCurve2D
- Returns:
- the cloned curve
toString
public String toString()
- Overrides:
toString
in class Object
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.