Resources Numerical accuracy
Calculations
Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.
Calculations
-
Arc through three points
The center, radius, start angle and signed sweep of the arc from the first point through the second to the third.
d = 2·(aₓ(m_y − b_y) + mₓ(b_y − a_y) + bₓ(a_y − m_y)); cₓ = Σ (x² + y²)·Δy ÷ d; r = hypot(a − c)
Arc through three points and angle measurement arcs.js64-bit- MarkupCraft
-
Arc as Bézier pieces
The arc as cubic Bézier segments of at most 90° each, for drawing and for the saved appearance.
n = ⌈|sweep| ÷ (π ÷ 2) − 1e-9⌉; k = (4 ÷ 3)·tan(step ÷ 4)
Arc through three points and angle measurement arcs.js64-bit- MarkupCraft
-
Arc length
The length of an arc markup in points.
length = r × |sweep|
Arc through three points and angle measurement arcs.js64-bit- MarkupCraft
-
Angle between two legs
The angle at a vertex between the directions to two other points, from 0° to 180°.
θ = acos((u·w) ÷ (|u|·|w|)) × 180 ÷ π
Arc through three points and angle measurement arcs.js64-bit- MarkupCraft
-
Angle as text
Writes the angle with a degree sign.
round(deg × 10ᵖ) ÷ 10ᵖ, p = 1 by default
Arc through three points and angle measurement arcs.js64-bit- MarkupCraft
-
Snap to 45°
Moves a point onto the nearest 45° direction from the point before it, keeping its distance.
a = round(atan2(dy, dx) ÷ (π ÷ 4)) × (π ÷ 4); p = from + (cos a, sin a) × hypot(dx, dy)
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Square from a corner
Makes the box from a fixed corner to the pointer square.
s = max(|dx|, |dy|); p = a + (sign dx, sign dy) × s
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Resize by a grip
The new box or points when a grip of a markup is dragged.
box: dragged edges = pointer; stroke: x′ = x₀ + (x − box x₀) ÷ box width × new width
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Move a markup
Shifts a markup's points, box and cut-outs by a distance.
x′ = x + dx; y′ = y + dy
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Simplify a freehand stroke
Drops the points of a pen or highlighter stroke that lie within a tolerance of the line through their neighbors.
d = |dy·pₓ − dx·p_y + bₓ·a_y − b_y·aₓ| ÷ L
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Inverse of a transform
The inverse of a 2-D affine transform.
det = a·d − b·c; inverse = adjugate ÷ det
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Line-up through two pairs of points
The move, turn and uniform scale that carries two picked points on one sheet onto two picked points on another.
s = |b| ÷ |a|; θ = atan2(b) − atan2(a); M = [s·cos θ, s·sin θ, −s·sin θ, s·cos θ, e, f]
Markup geometry while drawing and editing geom.js64-bit- MarkupCraft
-
Next point from a typed length and angle
Places the next point of a line or outline at a typed real length, along a typed angle or toward the pointer.
len = mm ÷ mmPerPt; a = (deg + page turn) × π ÷ 180; p = from + (cos a, sin a) × len
Markup geometry while drawing and editing sketch.js64-bit- MarkupCraft
-
Cleaned pen stroke to a markup
Turns what the stroke cleaner recognized (line, circle, arc, outline) into the points or box of a line, ellipse, arc, rectangle, polyline or polygon markup.
circle → box (c − r, c + r); arc → points at a₀, a₀ + sweep ÷ 2, a₁ on the circle
Markup geometry while drawing and editing pen-clean.js64-bit- MarkupCraft
-
Finished freehand stroke
What is stored when a pen or highlighter stroke is finished.
tolerance = 0.6 ÷ zoom (points)
Markup geometry while drawing and editing markupcraft.js64-bit- MarkupCraft
-
Align the old sheet in a comparison
The fit of the old sheet onto the new one from two points picked on each, and the scale and turn reported for it.
scale = hypot(M₀, M₁); turn = atan2(M₁, M₀) × 180 ÷ π
Markup geometry while drawing and editing markupcraft.js64-bit- MarkupCraft
-
Line up a picture by two points
The new box of a picture markup so two points on it land on two points on the sheet.
k = √(rw·rh ÷ (W·H)) × fit scale; box = center ± (w·k ÷ 2, h·k ÷ 2)
Markup geometry while drawing and editing markupcraft.js64-bit- MarkupCraft
-
Length measurement label
The dimension line, its end ticks and the length text of a measure markup.
len = hypot(bₓ − aₓ, b_y − a_y); label = len × mmPerPt, formatted
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Area measurement label
The area and perimeter text of an area markup, placed at the outline's centroid.
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Angle measurement label
The angle text of an angle markup and where it sits.
label = angle at the vertex, 1 decimal; position = vertex + (r + 1.2 × font size) along the bisector
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Count total
The running total shown beside the first mark of a count group.
n = number of marks
Markup outlines and measurement labels shapes.jsExact- MarkupCraft
-
Centroid of an outline
The area centroid of a closed outline, used to place the label of an area or a named zone.
k = xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ; cₓ = Σ (xᵢ + xᵢ₊₁)·k ÷ (3·Σ k)
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Circle-to-Bézier constant
The control-point factor for drawing a quarter circle as one cubic Bézier.
K = 4·(√2 − 1) ÷ 3 ≈ 0.5522847498
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Ellipse outline
An ellipse markup's outline as four cubic Bézier curves inside its box.
c = (p₀ + p₁) ÷ 2; r = (p₁ − p₀) ÷ 2; control offset = r × K
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Revision cloud outline
The scalloped outline of a cloud markup round its corner points.
n = max(1, round(edge ÷ arc)); step = edge ÷ n; bulge height = 0.6667 × step
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
Signed area of an outline
The signed shoelace area used to tell which way an outline runs.
A = Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ) ÷ 2
Markup outlines and measurement labels shapes.js64-bit- MarkupCraft
-
A number in an appearance stream
Turns a number into the text written in a PDF appearance stream.
text = v rounded to 3 decimals, trailing zeros removed; |v| < 1e-6 → 0
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Appearance stream of a markup
The drawing operators that show a markup in any PDF viewer.
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Private copy of a markup
The JSON kept with each annotation so it reopens exactly: points, box, cut-outs, style and the rest.
ar = round(rect × 1000) ÷ 1000
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Annotation rectangle
The /Rect of a markup's annotation, which is also the bounding box of its appearance.
rect = bounds ± 1 pt; each side ≥ 2 × line width + 2 pt
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Bounds of a display list
The box round everything a markup draws, used for its annotation rectangle.
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Rectangle differences of a box or ellipse
The /RD entry: how far the shape's outer edge sits inside the annotation rectangle on each side.
RD = [left, top, right, bottom] gaps between rect and box ± half line width, each ≥ 0
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Count marks as ink rings
Writes a count group as one Ink annotation with a small ring round each mark.
ring: 13 points at 30° steps, radius max(3, 0.8 × font size)
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Arc exported as a PolyLine
Writes an arc markup's /Vertices as points along the arc, because PDF has no arc annotation.
n = max(8, ⌈|sweep| ÷ (π ÷ 32)⌉); vertex k = c + r × (cos, sin)(a₀ + sweep × k ÷ n)
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Picture placement matrix
The matrix that paints a picture markup into its box, upright for the page's rotation.
cm = [u·W, −v·H, origin + v·H], each number to 4 decimals
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Scale as a /Measure dictionary
The sheet's scale in the form other PDF programs read: the factor from points to the unit and the display precision.
X.C = mmPerPt ÷ 304.8 (ft), ÷ 25.4 (in), ÷ 1000 (m), or mmPerPt (mm)
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Scale written on the page
Stores a sheet's calibration on its page in the saved PDF.
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Measured text in /Contents
The text other PDF programs show for a measurement: the length, the area and perimeter, the angle or the count.
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Flattened markup
Paints a markup into the page itself instead of saving it as an annotation.
Numbers written to the saved PDF pdf-write.js64-bit- MarkupCraft
-
Outline points of a PolyLine or Polygon
The points of a polyline, polygon, cloud or area markup read from an annotation.
Annotations and scales read from a PDF pdf-read.js32-bit in part- MarkupCraft
-
Stroke points of an Ink annotation
The points of pen and highlighter strokes, and of count rings, read from an annotation.
Annotations and scales read from a PDF pdf-read.js32-bit in part- MarkupCraft
-
End points of a Line annotation
The two end points of a line, arrow or length measurement read from an annotation.
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Box of a Square or Circle annotation
The box of a rectangle, ellipse or cloud rectangle markup from the annotation's /Rect.
box = rect inset by RD and by half the border width on each side
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Count mark from its ring
The position of each count mark, from the ring written for it in the ink list.
center = mean of the ring's points (the closing point dropped)
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Moved by another program
Decides whether a markup's private JSON still matches the annotation, or another program moved or resized it since.
|ar − rect| > 0.75 pt on any of the four numbers → use the annotation's own geometry
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Scale from another program's /Measure
A sheet calibration from the measurement dictionary another PDF program wrote.
mmPerPt = C × mm per unit (ft 304.8, in 25.4, m 1000, cm 10, mm 1)
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Which scale a sheet opens with
Picks the calibration of a page: MarkupCraft's own saved copy, else the page's measure viewport.
Annotations and scales read from a PDF pdf-read.js64-bit- MarkupCraft
-
Text size from an appearance stream
The size of the first visible text that another program's text box draws.
size = |Tf size × text matrix scale × cm scale|, rounded to 0.01
Annotations and scales read from a PDF freetext.js64-bit- MarkupCraft
-
Text size from a style string
Reads 12pt, 16px or 1.2em from a text box's style as points.
px × 0.75; em × 12; pt as written
Annotations and scales read from a PDF freetext.js64-bit- MarkupCraft
-
A page's paths as segments
Every drawn path of a page as straight segments in page coordinates.
curve point = Bézier at t = j ÷ 8, j = 1…8; p′ = CTM × p
Drawing comparison by vector paths vecdiff.js64-bit- MarkupCraft
A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.