Resources Numerical accuracy Calculation policy

Erection movie player

Draws the erection sequence as a moving 3D picture in the exported movie page.

How the precision is kept

The player draws on a 2D canvas from data that was already rounded for the movie (millimeters to whole numbers, times to 0.01 minute). It projects points with a turn and a tilt and sorts boxes by depth. Nothing it computes is saved or read as a result; the weights, radii and percentages in its captions are copied from the plan.

Calculations under this policy

2 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.

erection-html.js DetailCraft 0.8.1 32-bit, display only 2 calculations Reviewed

Tests tools/detailcraft-test/test-erection.mjs

Model point to screen

32-bit, display only

Where a model point is drawn on the canvas.

Two rotations and a scale to the canvas size. Used only to draw.

  • erection-html.js
  • lines 41 to 47
  • DetailCraft 0.8.1
function proj(p) {
  var x = p[0] - C[0], y = p[1] - C[1], z = p[2] - C[2];
  var cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
  var x1 = x * cy - y * sy, y1 = x * sy + y * cy;
  var s = Math.min(w, h) / (R * 1.5) * zoom;
  return [w / 2 + panx + x1 * s, h / 2 + pany - (z * cp + y1 * sp) * s, y1 * cp - z * sp];
}

Where a pick is at a given minute

32-bit, display only

The offset of a lifted piece from its final place while the movie plays.

An eased blend between the laydown point and the set point with an added arc of 800 mm. Animation only; the durations come from the plan.

  • erection-html.js
  • lines 49 to 59
  • DetailCraft 0.8.1
// where pick p is at minute T: null (not yet), or an offset [dx, dy, dz] from its set position, and its phase
function state(p) {
  if (T < p.t0) return { s: 'wait' };
  var dur = Math.max(1e-6, p.t1 - p.t0), f = (T - p.t0);
  var lay = [p.from[0] - p.cg[0], p.from[1] - p.cg[1], -p.cg[2] + 0];
  if (f < p.h) return { s: 'hook', o: lay, f: f / Math.max(p.h, 1e-6) };
  var tt = f - p.h;
  if (tt < p.tr) { var k = ease(tt / Math.max(p.tr, 1e-6)); return { s: 'carry', o: [lay[0] * (1 - k), lay[1] * (1 - k), lay[2] * (1 - k) + Math.sin(Math.PI * k) * 800], k: k }; }
  if (T < p.t1) return { s: 'set', o: [0, 0, 0] };
  return { s: 'done', o: [0, 0, 0] };
}

In detail

Method
Orthographic projection with yaw and pitch; painter's sort of box faces.
Number types
64-bit numbers on a 2D canvas.

Approach: Display only

Computed to draw the screen, often in 32-bit on the graphics processor. No number a person reads, saves or exports comes from it.

Every policy that takes this approach