P261 · Tool use

Preserve coordinate units through tool handoffs

Carry units, dimensions and origin with positions; normalize mixed coordinate sources before a downstream operation.

Editorially reviewed

These examples and illustrative results are independently authored teaching materials, not measured model results.

Use case

A PDF form combines an address rectangle extracted in points with a signature rectangle detected in pixels. The teaching input is a 600×800-point page and its 1200×1600-pixel full-page image; the signature rectangle is (200,400,600,600), measured from the upper left. Merging the numbers directly misplaces the signature.

Mechanism

  1. Carry page identity, page and image dimensions, units, origin and rectangle ordering with every region; confirm that the image represents the same full page.
  2. Normalize to upper-left point coordinates: multiply x by 600/1200 and y by 800/1600. Do not infer dimensions from filenames.
  3. If the writer uses a lower-left origin, subtract the bottom and top edges from page height to obtain (left,bottom,right,top). Apply this transform once.
  4. Check bounds and positive dimensions, write to a copy and inspect a render. Stop positioning if cropping or rotation cannot be established.

Bad example

Write the name into this PDF's signature field. The image rectangle is (200,400,600,600); use it directly as the PDF annotation rectangle and keep the extracted fields as they are.

Good example

Locate the signature field in a document copy. The page is 600×800 points and its full-page image is 1200×1600 pixels. The pixel rectangle uses upper-left (left,top,right,bottom)=(200,400,600,600). Convert to points with an explicit origin, then convert for the writer. Return both coordinates and a render check; do not write with an incomplete mapping.

Why the change matters

A coordinate array does not carry its own units or origin. Explicit normalization lets structural extraction and visual detection share a writer, while the recorded transforms expose a repeated flip or incorrect page mapping.

Observable expectation

The teaching calculation yields upper-left point coordinates (100,200,300,300) and a lower-left annotation rectangle (100,500,300,600). Its width is 200 points and height 100, inside the page. The rendered name must also appear in the visible signature field; arithmetic alone is insufficient.

Limits

These ratios assume a matching, unrotated full-page image. Cropping, nonzero page origins, rotation, enlarged excerpts and detection errors require additional transforms. Correct conversion does not establish text sizing or visual accuracy; the cited code excerpt is not a complete geometry validator.

Sources and evidence

Read the editorial criteria