Package toxi.geom
Class Circle
java.lang.Object
toxi.geom.Vec2D
toxi.geom.Ellipse
toxi.geom.Circle
- All Implemented Interfaces:
Comparable<ReadonlyVec2D>
,ReadonlyVec2D
,Shape2D
This class overrides
Ellipse
to define a 2D circle and provides
several utility methods for it, including factory methods to construct
circles from points.-
Nested Class Summary
Nested classes/interfaces inherited from class toxi.geom.Vec2D
Vec2D.Axis
-
Field Summary
Fields inherited from class toxi.geom.Ellipse
DEFAULT_RES
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the point is within the given shape.static Circle
from2Points
(Vec2D p1, Vec2D p2) Factory method to construct a circle which has the two given points lying on its perimeter.static Circle
from3Points
(Vec2D p1, Vec2D p2, Vec2D p3) Factory method to construct a circle which has the three given points lying on its perimeter.float
Computes the approximate circumference of the ellipse, using this equation:2 * PI * sqrt(1/2 * (rx*rx+ry*ry))
.float
Vec2D[]
Vec2D[]
static Circle
newBoundingCircle
(List<Vec2D> vertices) setRadius
(float r) Methods inherited from class toxi.geom.Ellipse
getArea, getBoundingCircle, getBounds, getEdges, getFoci, getRadii, getRandomPoint, setRadii, setRadii, toPolygon2D, toPolygon2D
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
-
Constructor Details
-
Circle
public Circle() -
Circle
-
Circle
public Circle(float radius) -
Circle
public Circle(float x, float y, float radius) -
Circle
-
-
Method Details
-
from2Points
Factory method to construct a circle which has the two given points lying on its perimeter. If the points are coincident, the circle will have a radius of zero.- Parameters:
p1
-p2
-- Returns:
- new circle instance
-
from3Points
Factory method to construct a circle which has the three given points lying on its perimeter. The function returns null, if the 3 points are co-linear (in which case it's impossible to find a circle). Based on CPP code by Paul Bourke: http://local.wasp.uwa.edu.au/~pbourke/geometry/circlefrom3/- Parameters:
p1
-p2
-p3
-- Returns:
- new circle instance or null
-
newBoundingCircle
-
containsPoint
Description copied from interface:Shape2D
Checks if the point is within the given shape.- Specified by:
containsPoint
in interfaceShape2D
- Overrides:
containsPoint
in classEllipse
- Returns:
- true, if inside
-
getCircumference
public float getCircumference()Description copied from class:Ellipse
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 interfaceShape2D
- Overrides:
getCircumference
in classEllipse
- Returns:
- circumference
-
getRadius
public float getRadius() -
getTangentPoints
-
intersectsCircle
-
setRadius
-