class Geometry · Computations
Arcs
Computations on circular arcs: creating them (from three points, a pin, a sagitta, a circle), points, pins and directions along them, length, area and sweep angle.
An arc is given by its start, middle and end point, which fix the circle, the extent and the direction.
Static methods
arc3Pstatic
static arc3P(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Arc | null): ArcCreates the arc that starts at p1, passes through p2 and ends at p3 (like
Circles.circle3P for circles). E.g. an arc bent by three handles.
The middle point decides which way the arc runs, so there is no direction to choose. Three points on a line have no arc: the result is NaN.
p1- The start of the arc.
p2- A point the arc passes through.
p3- The end of the arc.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns The arc through the three points.
arcAtstatic
static arcAt(center: Point | VectorLike, radius: Real | NumberLike, startAngle: Real | NumberLike, sweepAngle: Real | NumberLike, result?: Arc | null): ArcConstructs an arc from a center point, radius, start angle, and sweep angle.
center- The center of the underlying circle.
radius- The radius of the arc.
startAngle- The angle at which the arc begins, in radians.
sweepAngle- The angular extent of the arc, in radians. Positive values sweep clockwise on screen; negative values sweep counter-clockwise. The sweep is limited to one full turn (+-2π).
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc starting at startAngle and sweeping by sweepAngle.
arcAtPinstatic
static arcAtPin(pin: Pin | PinLike, sweepAngle: Real | NumberLike, result?: Arc | null): ArcCreates an arc from a pin: centered at the pin's position, starting at the pin's tip (the
pin's length is the radius) and sweeping by sweepAngle. E.g. a clock hand's sweep:
Arcs.arcAtPin(hand, Math.PI / 2, arc).
A positive sweep runs clockwise on the screen (y pointing down), as in arcAt; the sweep is
limited to one full turn either way. Turned copies of the pin (Pins.rotateBy) give turned
arcs without angle math.
pin- The center (position), radius (length) and start direction.
sweepAngle- The angle the arc covers, in radians; positive clockwise.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns The arc.
arcBetweenstatic
static arcBetween(center: Point | VectorLike, radius: Real | NumberLike, startAngle: Real | NumberLike, endAngle: Real | NumberLike, clockwise: Bool | BoolLike, result?: Arc | null): ArcConstructs an arc from a center point, radius, start angle, and end angle, with explicit winding direction.
center- The center of the underlying circle.
radius- The radius of the arc.
startAngle- The angle at which the arc begins, in radians.
endAngle- The angle at which the arc ends, in radians.
clockwise- If
true, the arc travels clockwise fromstartAngletoendAngle; otherwise counter-clockwise. resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc from startAngle to endAngle in the specified winding direction.
arcFromCirclestatic
static arcFromCircle(circle: Circle | ShapeLike, startAngle: Real | NumberLike, sweepAngle: Real | NumberLike, result?: Arc | null): ArcConstructs an arc on an existing circle between two angles with a given sweep.
circle- The circle on which the arc lies.
startAngle- The angle at which the arc begins, in radians.
sweepAngle- The angular extent of the arc, in radians. Positive values sweep clockwise on screen; negative values sweep counter-clockwise. The sweep is limited to one full turn (+-2π).
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc on circle starting at startAngle and sweeping by sweepAngle.
arcFromPointsstatic
static arcFromPoints(center: Point | VectorLike, start: Point | VectorLike, end: Point | VectorLike, clockwise: Bool | BoolLike, result?: Arc | null): ArcCreates an arc around a center from a start point to the direction of an end point, e.g. a
wedge or an angle marker from a center and two handles: Arcs.arcFromPoints(center, a, b, true, arc).
The radius is the distance from center to start; end only gives the direction where the
arc ends (its distance is not used). clockwise picks one of the two arcs, clockwise on the
screen (y pointing down) as in arcBetween.
center- The center of the arc.
start- The start of the arc.
end- A point in the direction where the arc ends.
clockwisetrue: from start to end clockwise on the screen;false: counterclockwise.resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns The arc.
arcFromSagittastatic
static arcFromSagitta(start: Point | VectorLike, end: Point | VectorLike, sagitta: Real | NumberLike, result?: Arc | null): ArcConstructs an arc from two endpoints and a sagitta (the signed height from the chord midpoint to the arc midpoint). Positive sagitta curves to the left of the start-to-end direction; negative curves to the right.
start- The start point of the arc.
end- The end point of the arc.
sagitta- The signed perpendicular distance from the chord midpoint to the arc midpoint.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc from start to end with the specified curvature. A sagitta of 0 gives a straight arc (infinite radius).
areastatic
static area(arc: Arc | ShapeLike, result?: Real | null): RealComputes the area of the circular sector defined by the arc.
arc- The arc whose sector area is computed.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The area of the sector swept by arc.
boundingBoxstatic
static boundingBox(arc: Arc | ShapeLike, result?: Box | null): BoxComputes the axis-aligned bounding box of the arc.
arc- The arc whose bounding box is computed.
resultoptional- Optional
Boxto write the result into; it is returned. Without it, a newBoxis returned.
Returns The smallest axis-aligned box that contains all points on arc.
centerstatic
static center(arc: Arc | ShapeLike, result?: Point | null): PointReturns the center of the underlying circle of the arc.
arc- The arc to query.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The center point of the circle on which arc lies.
chordLengthstatic
static chordLength(arc: Arc | ShapeLike, result?: Real | null): RealComputes the straight-line distance between the start and end points of the arc.
arc- The arc to measure.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The length of the chord from the start point to the end point of arc.
closestPointstatic
static closestPoint(arc: Arc | ShapeLike, p: Point | VectorLike, result?: Point | null): PointComputes the closest point on the arc to a given point. If the projection of the point falls outside the arc's angular range, the nearest endpoint is returned.
arc- The arc 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 arc closest to p.
closestPositionstatic
static closestPosition(arc: Arc | ShapeLike, p: Point | VectorLike, result?: Real | null): RealComputes the normalized position of the closest point on the arc to a given point. If the projection falls outside the arc's angular range, 0 or 1 is returned for the nearest endpoint.
arc- The arc 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 arc closest to p.
copystatic
directionAtstatic
static directionAt(arc: Arc | ShapeLike, ratio: Real | NumberLike, result?: Vector | null): VectorComputes the tangent direction at a normalized position along the arc. The direction always points in the direction of travel.
arc- The arc to sample.
ratio- A value in [0, 1] where 0 is the start and 1 is the end of the arc.
resultoptional- Optional
Vectorto write the result into; it is returned. Without it, a newVectoris returned.
Returns The tangent direction at the specified ratio along arc.
distanceTostatic
static distanceTo(arc: Arc | ShapeLike, p: Point | VectorLike, result?: Real | null): RealComputes the shortest distance from a point to the arc.
arc- The arc 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 arc.
endDirectionstatic
static endDirection(arc: Arc | ShapeLike, result?: Vector | null): VectorReturns the tangent direction at the end of the arc.
arc- The arc to query.
resultoptional- Optional
Vectorto write the result into; it is returned. Without it, a newVectoris returned.
Returns The tangent direction at the end point of arc.
endPointstatic
inflatestatic
static inflate(arc: Arc | ShapeLike, delta: Real | NumberLike, result?: Arc | null): ArcReturns an arc with the same center and angular range as the specified arc, with its radius adjusted by a given delta.
arc- The arc to inflate.
delta- The amount by which to grow the radius. Negative values shrink the arc.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc with the same center and sweep as arc and a radius increased by delta.
isClockwisestatic
static isClockwise(arc: Arc | ShapeLike, result?: Bool | null): BoolDetermines whether the arc travels in the clockwise direction.
arc- The arc to query.
resultoptional- Optional
Boolto write the result into; it is returned. Without it, a newBoolis returned.
Returns true if arc travels clockwise; otherwise false.
lenstatic
midPointstatic
static midPoint(arc: Arc | ShapeLike, result?: Point | null): PointReturns the mid point of the arc, which is the point at ratio 0.5.
arc- The arc to query.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The point at the midpoint of arc.
normalAtstatic
static normalAt(arc: Arc | ShapeLike, ratio: Real | NumberLike, left: boolean, result?: Vector | null): VectorComputes the normal direction at a normalized position along the arc. The normal is perpendicular to the tangent at that position.
arc- The arc to sample.
ratio- A value in [0, 1] where 0 is the start and 1 is the end of the arc.
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 arc.
pinAtstatic
static pinAt(arc: Arc | ShapeLike, ratio: Real | NumberLike, result?: Pin | null): PinComputes the pin (point with orientation) at a normalized position along the arc.
arc- The arc to sample.
ratio- A value in [0, 1] where 0 is the start and 1 is the end of the arc.
resultoptional- Optional
Pinto write the result into; it is returned. Without it, a newPinis returned.
Returns The pin on arc at the specified ratio, with orientation aligned to the tangent.
pointAtstatic
static pointAt(arc: Arc | ShapeLike, ratio: Real | NumberLike, result?: Point | null): PointComputes the point at a normalized position along the arc.
arc- The arc to sample.
ratio- A value in [0, 1] where 0 is the start and 1 is the end of the arc.
resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The point on arc at the specified ratio.
radiusstatic
reversestatic
static reverse(arc: Arc | ShapeLike, result?: Arc | null): ArcReturns an arc with the same path but opposite travel direction. The start and end points are swapped; the mid point is preserved.
arc- The arc to reverse.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc traversing the same path as arc in the opposite direction.
scalestatic
static scale(arc: Arc | ShapeLike, factor: Real | NumberLike, result?: Arc | null): ArcReturns an arc scaled around its own center by a given factor.
arc- The arc to scale.
factor- The scaling factor applied to the radius. Values greater than 1 enlarge the arc; values between 0 and 1 shrink it.
resultoptional- Optional
Arcto write the result into; it is returned. Without it, a newArcis returned.
Returns An arc with the same center and sweep as arc and a radius multiplied by factor.
startAnglestatic
static startAngle(arc: Arc | ShapeLike, result?: Real | null): RealReturns the start angle of the arc, measured from the positive x-axis.
arc- The arc to query.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The angle in radians at which arc begins.
startDirectionstatic
static startDirection(arc: Arc | ShapeLike, result?: Vector | null): VectorReturns the tangent direction at the start of the arc.
arc- The arc to query.
resultoptional- Optional
Vectorto write the result into; it is returned. Without it, a newVectoris returned.
Returns The tangent direction at the start point of arc.
startPointstatic
sweepAnglestatic
static sweepAngle(arc: Arc | ShapeLike, result?: Real | null): RealReturns the sweep angle of the arc. Positive values indicate a clockwise sweep on screen; negative values indicate a counter-clockwise sweep..
arc- The arc to query.
resultoptional- Optional
Realto write the result into; it is returned. Without it, a newRealis returned.
Returns The signed angular extent of arc in radians.
toCirclestatic
static toCircle(arc: Arc | ShapeLike, result?: Circle | null): CircleReturns the full circle on which the arc lies.
arc- The arc to convert.
resultoptional- Optional
Circleto write the result into; it is returned. Without it, a newCircleis returned.
Returns The circle passing through the three defining points of arc.
