Concepts

Scopes

How dynamic unit scopes, main scope gravity wells, and logarithmic infinite zoom work in duc.

Overview

The .duc format features a logarithmic Infinite Zoom and Unit Scope engine capable of spanning 64 orders of magnitude (10⁻³² to 10³²).

Instead of hardcoding a fixed unit for a canvas, .duc manages document geometry through unit scopes (mm, µm, nm, m, km, in, ft, mi), dynamically determining the active unit scale based on zoom depth and document settings.


Core Scope Concepts

1. Base Reference Unit (NEUTRAL_SCOPE)

All raw spatial data (element positions, stroke widths, bounding boxes, vector paths) are normalized relative to the meter (NEUTRAL_SCOPE = "m"). This guarantees zero coordinate distortion when rendering the same file across different CAD applications or unit systems.

2. Main Scope (main_scope)

The designated master unit of the document (e.g. mm for mechanical components, m for architectural site plans, mi for civil infrastructure). Stored in duc_global_state:

  • main_scope: The primary measure (e.g., mm, in, m).
  • scope_exponent_threshold: Defines the gravity well threshold for unit transitions.

3. Main Scope Gravity Well

To prevent rapid, jarring unit transitions when zooming near a project’s primary unit scale, .duc implements a gravity well effect.

When the current zoom exponent is within the scope_exponent_threshold from main_scope, the engine locks the active display unit to main_scope. Beyond this threshold, it smoothly falls back to natural logarithmic unit selection.


Supported Measurement Definitions

.duc supports both Metric and Imperial measurement unit definitions:

Metric Units (Powers of 10)

PrefixUnit NameFull NameExponent (10ˣ m)Scale Factor (m)
qmQuectoQuectometer-301 × 10⁻³⁰
rmRontoRontometer-271 × 10⁻²⁷
ymYoctoYoctometer-241 × 10⁻²⁴
zmZeptoZeptometer-211 × 10⁻²¹
amAttoAttometer-181 × 10⁻¹⁸
fmFemtoFemtometer-151 × 10⁻¹⁵
pmPicoPicometer-121 × 10⁻¹²
ÅAngstromAngstrom-101 × 10⁻¹⁰
nmNanoNanometer-91 × 10⁻⁹
µmMicroMicrometer-61 × 10⁻⁶
mmMilliMillimeter-30.001
cmCentiCentimeter-20.01
dmDeciDecimeter-10.1
mBaseMeter01.0
damDecaDecameter110.0
hmHectoHectometer2100.0
kmKiloKilometer31000.0
MmMegaMegameter61 × 10⁶
GmGigaGigameter91 × 10⁹
TmTeraTerameter121 × 10¹²
PmPetaPetameter151 × 10¹⁵
EmExaExameter181 × 10¹⁸
ZmZettaZettameter211 × 10²¹
YmYottaYottameter241 × 10²⁴
RmRonnaRonnameter271 × 10²⁷
QmQuettaQuettameter301 × 10³⁰

Imperial Units (Meter Equivalents)

PrefixUnit NameFull NameLog10 Exponent (m)Scale Factor (m)
µinMicroinchMicroinch-7.5952.54 × 10⁻⁸
thThouThou-4.5950.0000254
milMilMil-4.5950.0000254
lnLineLine-2.6740.00211667
inInchInch-1.5950.0254
hHandHand-0.9930.1016
ftFootFoot-0.5160.3048
ydYardYard-0.0390.9144
rdRodRod0.7015.0292
chChainChain1.30420.1168
furFurlongFurlong2.304201.168
miMileMile3.2071609.344
leaLeagueLeague3.6844828.032
auAstronomical UnitAstronomical Unit11.1751.496 × 10¹¹
lyLight YearLight Year15.9769.461 × 10¹⁵
pcParsecParsec16.4893.086 × 10¹⁶

Dynamic Unit Scaling

For details on how .duc preserves lossless geometric precision across different scopes without modifying an element’s original measure, see the Infinite Precision & Scoped Values page.

Edit on GitHub

Last updated on