Package toxi.geom
Class Ellipse
java.lang.Object
toxi.geom.Vec2D
toxi.geom.Ellipse
- All Implemented Interfaces:
Comparable<ReadonlyVec2D>,ReadonlyVec2D,Shape2D
- Direct Known Subclasses:
Circle
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the point is within the given shape.floatgetArea()Computes the area covered by the ellipse.Computes the bounding circle of the shape.Returns the ellipse's bounding rect.floatComputes the approximate circumference of the ellipse, using this equation:2 * PI * sqrt(1/2 * (rx*rx+ry*ry)).getEdges()Returns a list of the shape's perimeter edges.Vec2D[]getFoci()getRadii()Creates a random point within the ellipse using aBiasedFloatRangeto create a more uniform distribution.setRadii(float rx, float ry) Sets the radii of the ellipse to the new values.Sets the radii of the ellipse to the values given by the vector.Converts the shape into aPolygon2Dinstance (possibly via a default resolution, e.g.toPolygon2D(int res) Creates aPolygon2Dinstance 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, constrain, copy, cross, distanceTo, distanceToSquared, dot, equals, equals, equalsWithTolerance, floor, frac, fromTheta, getAbs, getCartesian, getComponent, getComponent, getConstrained, getConstrained, getFloored, getFrac, getInverted, getLimited, getMapped, getNormalized, getNormalizedTo, getPerpendicular, getPolar, getReciprocal, getReflected, getRotated, getRoundedTo, 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, positiveHeading, randomVector, randomVector, reciprocal, reflect, rotate, roundTo, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, setX, setY, signum, snapToAxis, sub, sub, sub, subSelf, subSelf, tangentNormalOfEllipse, to3DXY, to3DXZ, to3DYZ, toArray, toCartesian, toPolar, toString, x, y
-
Field Details
-
DEFAULT_RES
public static int DEFAULT_RES
-
-
Constructor Details
-
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
-
Ellipse
-
-
Method Details
-
containsPoint
Description copied from interface:Shape2DChecks if the point is within the given shape.- Specified by:
containsPointin interfaceShape2D- Returns:
- true, if inside
-
getArea
public float getArea()Computes the area covered by the ellipse. -
getBoundingCircle
Description copied from interface:Shape2DComputes the bounding circle of the shape.- Specified by:
getBoundingCirclein interfaceShape2D- Returns:
- circle
-
getBounds
Returns the ellipse's bounding rect. -
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:
getCircumferencein interfaceShape2D- Returns:
- circumference
-
getEdges
Description copied from interface:Shape2DReturns a list of the shape's perimeter edges. -
getFoci
- Returns:
- the focus
-
getRadii
- Returns:
- the 2 radii of the ellipse as a Vec2D
-
getRandomPoint
Creates a random point within the ellipse using aBiasedFloatRangeto create a more uniform distribution.- Specified by:
getRandomPointin interfaceShape2D- Returns:
- Vec2D
-
setRadii
Sets the radii of the ellipse to the new values.- Parameters:
rx-ry-- Returns:
- itself
-
setRadii
Sets the radii of the ellipse to the values given by the vector.- Parameters:
r-- Returns:
- itself
-
toPolygon2D
Description copied from interface:Shape2DConverts the shape into aPolygon2Dinstance (possibly via a default resolution, e.g. for circles/ellipses)- Specified by:
toPolygon2Din interfaceShape2D- Returns:
- shape as polygon
-
toPolygon2D
Creates aPolygon2Dinstance of the ellipse sampling it at the given resolution.- Parameters:
res- number of steps- Returns:
- ellipse as polygon
-