toxi.geom
Class Ellipse

java.lang.Object
  extended by toxi.geom.Vec2D
      extended by toxi.geom.Ellipse
All Implemented Interfaces:
java.lang.Comparable<ReadonlyVec2D>, ReadonlyVec2D, Shape2D
Direct Known Subclasses:
Circle

public class Ellipse
extends Vec2D
implements Shape2D

This class defines a 2D ellipse and provides several utility methods for it.


Nested Class Summary
 
Nested classes/interfaces inherited from class toxi.geom.Vec2D
Vec2D.Axis
 
Field Summary
 
Fields inherited from class toxi.geom.Vec2D
MAX_VALUE, MIN_VALUE, x, X_AXIS, y, Y_AXIS, ZERO
 
Constructor Summary
Ellipse()
           
Ellipse(float rx, float ry)
           
Ellipse(float x, float y, float r)
           
Ellipse(float x, float y, float rx, float ry)
           
Ellipse(ReadonlyVec2D v, float r)
           
Ellipse(ReadonlyVec2D v, ReadonlyVec2D r)
           
 
Method Summary
 boolean containsPoint(ReadonlyVec2D p)
          Checks if the point is within the given shape.
 float getArea()
          Computes the area covered by the ellipse.
 float getCircumference()
          Computes the approximate circumference of the ellipse, using this equation: 2 * PI * sqrt(1/2 * (rx*rx+ry*ry)).
 Vec2D[] getFoci()
           
 Vec2D getRadii()
           
 Ellipse setRadii(float rx, float ry)
          Sets the radii of the ellipse to the new values.
 Ellipse setRadii(ReadonlyVec3D r)
          Sets the radii of the ellipse to the values given by the vector.
 Polygon2D toPolygon2D(int res)
          Creates a Polygon2D instance of the ellipse sampling it at the given resolution.
 
Methods inherited from class toxi.geom.Vec2D
abs, add, add, add, addSelf, addSelf, angleBetween, angleBetween, bisect, clear, compareTo, constrain, constrain, copy, cross, distanceTo, distanceToSquared, dot, equals, equalsWithTolerance, floor, frac, fromTheta, getAbs, getComponent, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getNormalized, getNormalizedTo, getPerpendicular, getReciprocal, getReflected, getRotated, getSignum, hashCode, heading, interpolateTo, interpolateTo, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInCircle, isInRectangle, isInTriangle, isMajorAxis, isZeroVector, jitter, jitter, jitter, jitter, jitter, jitter, limit, magnitude, magSquared, max, max, maxSelf, min, min, minSelf, normalize, normalizeTo, perpendicular, randomVector, randomVector, reciprocal, reflect, rotate, roundToAxis, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, signum, sub, sub, sub, subSelf, subSelf, tangentNormalOfEllipse, to3DXY, to3DXZ, to3DYZ, toArray, toCartesian, toPolar, toString, x, y
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ellipse

public Ellipse()

Ellipse

public Ellipse(float rx,
               float ry)

Ellipse

public Ellipse(float x,
               float y,
               float r)

Ellipse

public Ellipse(float x,
               float y,
               float rx,
               float ry)

Ellipse

public Ellipse(ReadonlyVec2D v,
               float r)

Ellipse

public Ellipse(ReadonlyVec2D v,
               ReadonlyVec2D r)
Method Detail

containsPoint

public boolean containsPoint(ReadonlyVec2D p)
Description copied from interface: Shape2D
Checks if the point is within the given shape.

Specified by:
containsPoint in interface Shape2D
Returns:
true, if inside

getArea

public float getArea()
Computes the area covered by the ellipse.

Specified by:
getArea in interface Shape2D
Returns:
area

getCircumference

public float getCircumference()
Computes the approximate circumference of the ellipse, using this equation: 2 * PI * sqrt(1/2 * (rx*rx+ry*ry)). The precise value is an infinite series elliptical integral, but the approximation comes sufficiently close. See Wikipedia for more details: http://en.wikipedia.org/wiki/Ellipse

Specified by:
getCircumference in interface Shape2D
Returns:
circumference

getFoci

public Vec2D[] getFoci()
Returns:
the focus

getRadii

public Vec2D getRadii()
Returns:
the 2 radii of the ellipse as a Vec2D

setRadii

public Ellipse setRadii(float rx,
                        float ry)
Sets the radii of the ellipse to the new values.

Parameters:
rx -
ry -
Returns:
itself

setRadii

public Ellipse setRadii(ReadonlyVec3D r)
Sets the radii of the ellipse to the values given by the vector.

Parameters:
r -
Returns:
itself

toPolygon2D

public Polygon2D toPolygon2D(int res)
Creates a Polygon2D instance of the ellipse sampling it at the given resolution.

Parameters:
res - number of steps
Returns:
ellipse as polygon