class Geometry · Computations
Circles
Computations on circles: creating them (center and radius, two or three points, enclosing points), points, pins and directions on them, area, circumference and containment.
Static methods
areastatic
boundingBoxstatic
static boundingBox(circle: Circle | ShapeLike, result?: Box | null): BoxComputes the axis-aligned bounding box of the specified circle.
circle- The circle whose bounding box is computed.
resultoptional- Optional box to store the result; if null, a new box is created.
Returns A box representing the bounds of the circle.
centerstatic
circle2Pstatic
static circle2P(p1: Point | VectorLike, p2: Point | VectorLike, result?: Circle | null): CircleConstructs a circle passing through two points.
p1- The first point on the circle.
p2- The second point on the circle.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns A circle passing through p1 and p2.
circle3Pstatic
static circle3P(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Circle | null): CircleConstructs a circle passing through three points.
p1- The first point on the circle.
p2- The second point on the circle.
p3- The third point on the circle.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns A circle passing through p1, p2, and p3. Three distinct points on one line give a circle of infinite radius whose center is the midpoint of the two outermost points.
circleAtstatic
static circleAt(center: Point | VectorLike, radius: Real | NumberLike, result?: Circle | null): CircleConstructs a circle with a specified center and radius.
center- The center of the circle.
radius- The radius of the circle.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns The circle with the given center and radius.
circumferencestatic
static circumference(circle: Circle | ShapeLike, result?: Real | null): RealComputes the circumference of the specified circle.
circle- The circle whose circumference is computed.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The circumference of circle.
closestPointstatic
static closestPoint(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Point | null): PointComputes the closest point on the circle to a given point. If the point coincides with the center, the first defining point is returned.
circle- The circle to project onto.
p- The point to project.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The point on circle closest to p.
closestPositionstatic
static closestPosition(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Real | null): RealComputes the normalized position of the closest point on the circle to a given point. The position is measured along the travel direction defined by the winding order of the circle's three defining points, starting at the first defining point.
circle- The circle to project onto.
p- The point to project.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns A value in [0, 1) representing the position along circle closest to p.
containsPointstatic
static containsPoint(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Bool | null): BoolDetermines whether a circle contains a given point.
circle- The circle to test.
p- The point to test.
resultoptional- Optional
Boolto write the result into; it is returned. Without it, a newBoolis returned.
Returns true if circle contains p; otherwise false.
copystatic
diameterstatic
directionAtstatic
static directionAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Vector | null): VectorComputes the tangent direction at a normalized position along the circle. The direction follows the travel direction defined by the winding order of the circle's three defining points.
circle- The circle to sample.
ratio- A value in [0, 1] where 0 corresponds to the first defining point. Values outside this range wrap around.
resultoptional- Optional
Vectorto write the result into; it is returned. Without it, a newVectoris returned.
Returns The tangent direction at the specified ratio along circle.
distanceTostatic
static distanceTo(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Real | null): RealComputes the shortest distance from a point to the circle.
circle- The circle to measure against.
p- The point to measure from.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The minimum distance from p to any point on circle.
enclosingstatic
static enclosing(circles: Circle[], result?: Circle | null): CircleThe smallest circle that encloses all circles, e.g. an outline around packed bubbles:
Circles.enclosing(bubbles, outline).
Exact and the same for the same input. Circles whose center or radius is not a finite number are skipped; with none left, the result has a NaN center and radius.
circles- The circles to enclose.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns The smallest enclosing circle.
enclosingPointsstatic
static enclosingPoints(points: Sequence<Vector> | VectorsLike, result?: Circle | null): CircleThe smallest circle that encloses all points: Circles.enclosingPoints(points, ring).
Points that are not finite are skipped; with none left, the result has a NaN center and radius.
points- The points to enclose.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns The smallest enclosing circle.
getCircleCenterstatic
static getCircleCenter(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Point | null): PointComputes the center of a circle defined by three points.
p1- The first point on the circle.
p2- The second point on the circle.
p3- The third point on the circle.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The center point of the circle passing through the three points.
inflatestatic
static inflate(circle: Circle | ShapeLike, delta: Real | NumberLike, result?: Circle | null): CircleReturns a circle with the same center as the specified circle, inflated by a given radius delta.
circle- The circle to inflate.
delta- The amount by which to grow the radius. Negative values shrink the circle.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns A circle with the same center as circle and a radius increased by delta.
isClockwisestatic
static isClockwise(circle: Circle | ShapeLike, result?: Bool | null): BoolDetermines whether the circle travels in the clockwise direction, as defined by the winding order of its three defining points.
circle- The circle to query.
resultoptional- Optional
Boolto write the result into; it is returned. Without it, a newBoolis returned.
Returns true if the winding order of circle is clockwise; otherwise false.
isCounterClockwisestatic
static isCounterClockwise(circle: Circle | ShapeLike, result?: Bool | null): BoolDetermines whether the circle travels in the counter-clockwise direction, as defined by the winding order of its three defining points.
circle- The circle to query.
resultoptional- Optional
Boolto write the result into; it is returned. Without it, a newBoolis returned.
Returns true if the winding order of circle is counter-clockwise; otherwise false.
normalAtstatic
static normalAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, left: boolean, result?: Vector | null): VectorComputes the normal direction at a normalized position along the circle. The normal is perpendicular to the tangent at that position.
circle- The circle to sample.
ratio- A value in [0, 1] where 0 corresponds to the first defining point. Values outside this range wrap around.
left- If
true, the normal points to the left of the travel direction; otherwise to the right. resultoptional- Optional
Vectorto write the result into; it is returned. Without it, a newVectoris returned.
Returns The normal direction at the specified ratio along circle.
pinAtstatic
static pinAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Pin | null): PinComputes the pin (point with orientation) at a normalized position along the circle. The pin's orientation is aligned with the tangent in the travel direction defined by the winding order of the circle's three defining points.
For a circle from Circles.circleAt(center, radius) (also visuals.circleAt), ratio 0 is at
9 o'clock and the ratios run clockwise on screen: 0.25 is at 12 o'clock, 0.5 at 3 o'clock.
circle- The circle to sample.
ratio- A value in [0, 1] where 0 corresponds to the first defining point. Values outside this range wrap around.
resultoptional- Optional
Pinto write the result into; it is returned. Without it, a newPinis returned.
Returns The pin on circle at the specified ratio.
pointAtstatic
static pointAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Point | null): PointComputes the point at a normalized position along the circle. The position is measured along the travel direction defined by the winding order of the circle's three defining points, starting at the first defining point.
For a circle from Circles.circleAt(center, radius) (also visuals.circleAt), ratio 0 is at
9 o'clock and the ratios run clockwise on screen: 0.25 is at 12 o'clock, 0.5 at 3 o'clock.
circle- The circle to sample.
ratio- A value in [0, 1] where 0 corresponds to the first defining point. Values outside this range wrap around.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The point on circle at the specified ratio.
radiusstatic
static radius(circle: Circle | ShapeLike, result?: Real | null): RealReturns the radius of a given circle.
circle- The circle to query.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The radius of circle; positive infinity if its three defining points are distinct and lie on one line.
scalestatic
static scale(circle: Circle | ShapeLike, factor: Real | NumberLike, result?: Circle | null): CircleReturns a circle scaled around its own center by a given factor.
circle- The circle to scale.
factor- The scaling factor applied to the radius. Values greater than 1 enlarge the circle; values between 0 and 1 shrink it.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns A circle with the same center as circle and a radius multiplied by factor.
