Works out the point a click stands for when ortho is on, and the coordinates, distance and angle shown in the status line and beside the cursor.
How the precision is kept
With ortho the picked point is the projection of the cursor onto the nearer of the two axes through the base point, in 64-bit. The readouts are computed from the same unrounded point with Math.hypot and atan2 and only then written as text: with the drawing's length and angle formats in the model, and with at most 4 decimals on a sheet.
Calculations under this policy
6 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
The point a click stands for when ortho is on and there is a base point.
u = c·Δx + s·Δy; v = −s·Δx + c·Δy; point = base + u·(c, s) if |u| ≥ |v|, else base + v·(−s, c)
The cursor's offset from the base point is projected on the two axes of the coordinate system in force, c and s being the cosine and sine of its angle. With no user coordinate system c = 1 and s = 0 exactly, so one coordinate of the result equals the base point's bit for bit and the other is base + (cursor − base), which can differ from the cursor's coordinate in the last bit. With a turned system both coordinates pass through the sine and cosine.
cadcraft.js
lines 901 to 904
CadCraft 0.8.2
if (settings.ortho && base) {
const c = Math.cos(ua), s = Math.sin(ua), dx = raw.x - base.x, dy = raw.y - base.y, u = c * dx + s * dy, v = -s * dx + c * dy;
return Math.abs(u) >= Math.abs(v) ? { x: base.x + c * u, y: base.y + s * u } : { x: base.x - s * v, y: base.y + c * v };
}
Coordinates, distance and angle in the status line
64-bit
The cursor's coordinates and, during a command, the distance and angle from the base point.
The coordinates are the point in the user coordinate system (ucs.js toUcs). The distance is one Math.hypot from the base point in world coordinates and the angle is one atan2 minus the system's angle. All three are turned into text after the calculation, so the only rounding in the readout is that of the drawing's length and angle formats.
A length written for the status line, the tracking labels and the cursor box.
In the model the value goes to units.js formatLength with the drawing's units and precision. On a sheet it goes to ui-util.js fmt, which writes at most 4 decimals and shows a value under 1e-10 in size as 0.
cadcraft.js
lines 1432 to 1433
CadCraft 0.8.2
/** A length / an area in the drawing's format (paper units on a sheet stay decimal). */
function fmtL(v) { return doc.layout ? fmt(v) : formatLength(v, unitsOf(doc.meta)); }
Distance and angle beside the cursor
64-bit
The live distance or angle shown in the box by the cursor while a command waits for one.
d = √(Δx² + Δy²); angle = atan2(Δy, Δx), normalized to 0…360°
One Math.hypot or one atan2 from the prompt's base point to the cursor, written with the same formats as the status line. Text being typed is shown in place of the computed value.
The width and height of the chosen area at the chosen scale, shown in the Plot dialog.
w = (maxX − minX) × s, shown as round(w × 10) ÷ 10
The area's extent is multiplied by the sheet's scale factor and rounded to 0.1 with Math.round(v × 10) ÷ 10 for the dialog's information line. The rounded value is only shown; the sheet comes from plot.js modelSheet, which is given the unrounded area.
The number a property is compared with in the Quick select dialog.
The text is read as a length in the drawing's format by units.js parseLength. When that returns null it falls back to parseFloat, which reads a leading number and ignores anything after it, so 12abc is taken as 12.
Ortho: dot products of the cursor offset with the axes of the coordinate system in force. Readouts: distance and angle from the base point.
Number types
64-bit numbers; text is produced by units.js formatLength and fmtAngle, or by ui-util.js fmt.
Tolerances
1e-9 drawing units, absolute: two snap points count as the same acquired tracking point. A plot window needs both sides over 1e-9. The reach handed to polar and object-snap tracking is 8 screen pixels ÷ zoom.
Limits
On a sheet lengths show at most 4 decimals. The plot dialog's area size is rounded to 0.1 mm. A number typed in Quick select that is not a valid length falls back to parseFloat, which reads a leading number and ignores what follows.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.