PavePave
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
  • Arc

@baku89/pave v1.0.1


@baku89/pave / Arc

Arc

A collection of functions to handle arcs represented with SegmentA.

Utilities

toCenterParameterization()

toCenterParameterization(arg): object

Defined in: Arc.ts:55

Converts the Arc command to a center parameterization that can be used in Context2D.ellipse(). https://observablehq.com/@awhitty/svg-2-elliptical-arc-to-canvas-path2d

Parameters

ParameterType
argBareSegmentA

Returns

object

NameTypeDefault value
anglesAngleRange-
centervec2-
radiivec2-
sweepbooleantrue
xAxisRotationnumber-

Other

approximateByCubicBeziers()

approximateByCubicBeziers(arc, tolerance): VertexC[]

Defined in: Arc.ts:151

Approximates the arc by cubic Béziers so that the deviation from the true arc stays within tolerance. The sweep is split into equal steps of at most 90°, whose size is solved from the sixth-power error law of the cubic arc approximation. For elliptic arcs the larger radius is used, which is conservative.

Parameters

ParameterTypeDefault valueDescription
arcBareSegmentAundefinedThe arc to approximate
tolerancenumber0.05The maximum deviation allowed, in the same unit as the coordinates

Returns

VertexC[]

The vertices of the approximating cubics, excluding the start point


bounds()

bounds(arg): Rect

Defined in: Arc.ts:239

Calculates the bound of given arc.

Parameters

ParameterTypeDescription
argBareSegmentAThe arc segment to calculate

Returns

Rect

The bound of the arc

Example


curvature()

curvature(arc, loc): number

Defined in: Arc.ts:624

Returns the signed curvature at the given location. Positive when the arc turns towards its normal side.

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

number


derivative()

derivative(arc, loc): vec2

Defined in: Arc.ts:403

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

vec2


divideAtTimes()

divideAtTimes(arc, times): VertexA[]

Defined in: Arc.ts:457

Parameters

ParameterType
arcBareSegmentA
timesIterable<number>

Returns

VertexA[]


ellipticArcLength()

ellipticArcLength(radii, angles): number

Defined in: Arc.ts:534

Computes the arc length of an ellipse over a range of centric angles.

The integrand |d/dt (rx cos t, ry sin t)| is smooth but has sharp dips near the minor axis of an eccentric ellipse, so a single fixed-order quadrature over a wide span loses accuracy. The span is therefore cut at quadrant boundaries and Gauss–Legendre quadrature is applied to each piece (see ellipticArcLengthRad for the accuracy this achieves).

Parameters

ParameterType
radiivec2
anglesAngleRange

Returns

number


isCircular()

isCircular(arc): boolean

Defined in: Arc.ts:555

Returns true if the arc lies on a circle (equal radii).

Parameters

ParameterType
arcBareSegmentA

Returns

boolean


isStraight()

isStraight(arc, tolerance): boolean

Defined in: Arc.ts:496

Parameters

ParameterTypeDefault value
arcBareSegmentAundefined
tolerancenumber0

Returns

boolean


isZero()

isZero(arg): boolean

Defined in: Arc.ts:491

Returns true if the length of arc segment is zero.

Parameters

ParameterType
argBareSegmentA

Returns

boolean


length()

length(arg): number

Defined in: Arc.ts:370

Parameters

ParameterType
argBareSegmentA

Returns

number


normal()

normal(arc, loc): vec2

Defined in: Arc.ts:422

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

vec2


of()

of(start, radii, xAxisRotation, largeArcFlag, sweepFlag, point): SegmentA

Defined in: Arc.ts:34

Parameters

ParameterType
startvec2
radiivec2
xAxisRotationnumber
largeArcFlagboolean
sweepFlagboolean
pointvec2

Returns

SegmentA


offset()

offset(arc, distance, tolerance): Path

Defined in: Arc.ts:652

Returns the raw parallel curve of the arc at the given signed distance along its normal, as an open path. Circular arcs stay circular arcs (A); elliptic arcs are approximated by cubic Béziers within tolerance.

Parameters

ParameterTypeDefault value
arcBareSegmentAundefined
distancenumberundefined
tolerancenumber0.05

Returns

Path


point()

point(arc, loc): vec2

Defined in: Arc.ts:394

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

vec2


tangent()

tangent(arc, loc): vec2

Defined in: Arc.ts:418

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

vec2


tangentTimes()

tangentTimes(arc, direction): number[]

Defined in: Arc.ts:579

Sorted t values in (0, 1) where the tangent of the arc is parallel to direction.

Parameters

ParameterTypeDescription
arcBareSegmentA-
directionvec2The direction to compare the tangent with. Its length does not matter.

Returns

number[]


tangentTimesFrom()

tangentTimesFrom(arc, origin): number[]

Defined in: Arc.ts:599

Sorted t values in (0, 1) where the line from origin to the arc is tangent to it. There are none when origin lies inside the ellipse.

Parameters

ParameterTypeDescription
arcBareSegmentA-
originvec2The point the tangents pass through

Returns

number[]


toTime()

toTime(arc, loc): number

Defined in: Arc.ts:375

Parameters

ParameterType
arcBareSegmentA
locSegmentLocation

Returns

number


transform()

transform(arc, matrix): SegmentA

Defined in: Arc.ts:284

Transforms the given arc segment with the given matrix.

Parameters

ParameterType
arcBareSegmentA
matrixmat2d

Returns

SegmentA

See

https://gist.github.com/timo22345/9413158#file-flatten-js-L443-L547


trim()

trim(arc, start, end): SegmentA

Defined in: Arc.ts:426

Parameters

ParameterType
arcBareSegmentA
startSegmentLocation
endSegmentLocation

Returns

SegmentA

Edit this page