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

static area(circle: Circle | ShapeLike, result?: Real | null): Real

Computes the area of the specified circle.

circle
The circle whose area is computed.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is returned.

Returns The area of circle.

boundingBoxstatic

static boundingBox(circle: Circle | ShapeLike, result?: Box | null): Box

Computes the axis-aligned bounding box of the specified circle.

circle
The circle whose bounding box is computed.
result optional
Optional box to store the result; if null, a new box is created.

Returns A box representing the bounds of the circle.

centerstatic

static center(circle: Circle | ShapeLike, result?: Point | null): Point

Returns the center of a given circle.

circle
The circle to query.
result optional
Optional Point to write the result into; it is returned. Without it, a new Point is returned.

Returns The center point of circle.

circle2Pstatic

static circle2P(p1: Point | VectorLike, p2: Point | VectorLike, result?: Circle | null): Circle

Constructs a circle passing through two points.

p1
The first point on the circle.
p2
The second point on the circle.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is returned.

Returns A circle passing through p1 and p2.

circle3Pstatic

static circle3P(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Circle | null): Circle

Constructs 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.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is 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): Circle

Constructs a circle with a specified center and radius.

center
The center of the circle.
radius
The radius of the circle.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is returned.

Returns The circle with the given center and radius.

circumferencestatic

static circumference(circle: Circle | ShapeLike, result?: Real | null): Real

Computes the circumference of the specified circle.

circle
The circle whose circumference is computed.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is returned.

Returns The circumference of circle.

closestPointstatic

static closestPoint(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Point | null): Point

Computes 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.
result optional
Optional Point to write the result into; it is returned. Without it, a new Point is returned.

Returns The point on circle closest to p.

closestPositionstatic

static closestPosition(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Real | null): Real

Computes 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.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is 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): Bool

Determines whether a circle contains a given point.

circle
The circle to test.
p
The point to test.
result optional
Optional Bool to write the result into; it is returned. Without it, a new Bool is returned.

Returns true if circle contains p; otherwise false.

copystatic

static copy(circle: Circle | ShapeLike, result?: Circle | null): Circle

Creates a copy of the specified circle.

circle
The circle to copy.
result optional
Optional circle to store the result; if null, a new circle is created.

Returns A copy of the specified circle.

diameterstatic

static diameter(circle: Circle | ShapeLike, result?: Real | null): Real

Computes the diameter of the specified circle.

circle
The circle whose diameter is computed.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is returned.

Returns The diameter of circle.

directionAtstatic

static directionAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Vector | null): Vector

Computes 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.
result optional
Optional Vector to write the result into; it is returned. Without it, a new Vector is returned.

Returns The tangent direction at the specified ratio along circle.

distanceTostatic

static distanceTo(circle: Circle | ShapeLike, p: Point | VectorLike, result?: Real | null): Real

Computes the shortest distance from a point to the circle.

circle
The circle to measure against.
p
The point to measure from.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is returned.

Returns The minimum distance from p to any point on circle.

enclosingstatic

static enclosing(circles: Circle[], result?: Circle | null): Circle

The 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.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is returned.

Returns The smallest enclosing circle.

enclosingPointsstatic

static enclosingPoints(points: Sequence<Vector> | VectorsLike, result?: Circle | null): Circle

The 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.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is returned.

Returns The smallest enclosing circle.

getCircleCenterstatic

static getCircleCenter(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Point | null): Point

Computes 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.
result optional
Optional Point to write the result into; it is returned. Without it, a new Point is 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): Circle

Returns 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.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is 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): Bool

Determines whether the circle travels in the clockwise direction, as defined by the winding order of its three defining points.

circle
The circle to query.
result optional
Optional Bool to write the result into; it is returned. Without it, a new Bool is returned.

Returns true if the winding order of circle is clockwise; otherwise false.

isCounterClockwisestatic

static isCounterClockwise(circle: Circle | ShapeLike, result?: Bool | null): Bool

Determines 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.
result optional
Optional Bool to write the result into; it is returned. Without it, a new Bool is 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): Vector

Computes 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.
result optional
Optional Vector to write the result into; it is returned. Without it, a new Vector is returned.

Returns The normal direction at the specified ratio along circle.

pinAtstatic

static pinAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Pin | null): Pin

Computes 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.
result optional
Optional Pin to write the result into; it is returned. Without it, a new Pin is returned.

Returns The pin on circle at the specified ratio.

pointAtstatic

static pointAt(circle: Circle | ShapeLike, ratio: Real | NumberLike, result?: Point | null): Point

Computes 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.
result optional
Optional Point to write the result into; it is returned. Without it, a new Point is returned.

Returns The point on circle at the specified ratio.

radiusstatic

static radius(circle: Circle | ShapeLike, result?: Real | null): Real

Returns the radius of a given circle.

circle
The circle to query.
result optional
Optional Real to write the result into; it is returned. Without it, a new Real is 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): Circle

Returns 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.
result optional
Optional Circle to write the result into; it is returned. Without it, a new Circle is returned.

Returns A circle with the same center as circle and a radius multiplied by factor.