Resources Numerical accuracy Calculation policy

Illuminance values written on the lighting plot

Places the fixtures of a plot in millimeters for the photometric engine and writes the computed lux at each grid point as text in the drawing.

How the precision is kept

This file is the adapter around the photometric engine. Fixture positions are divided by the drawing scale in 64-bit numbers. The value written at each grid point is the engine's lux rounded to a whole number, and when the grid has more points than the cap, only every n-th value is written.

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.

addons/lighting/lib/lux.js CadCraft 0.8.2 64-bit 2 calculations Reviewed

Tests None found by the review

Fixture positions for the calculation

64-bit

Each fixture's position in millimeters, its height and its aim, as the engine reads them.

p = (x ÷ k, y ÷ k, height)

One division per coordinate by the fixture's own scale; a scale that is missing or not above zero is taken as 1. Every fixture is aimed straight down.

  • addons/lighting/lib/lux.js
  • lines 31 to 41
  • CadCraft 0.8.2
export function luminairesOf(fixtures, photos, { mountMm = 6000 } = {}) {
  const luminaires = [], skipped = [];
  for (const f of fixtures.slice(0, LIMITS.fixtures)) {
    const photo = photos[f.d?.type];
    if (!photo) { skipped.push({ id: f.id, why: 'nofile' }); continue; }
    const k = f.d.k > 0 ? f.d.k : 1;
    const h = Number.isFinite(f.d.height) && f.d.height > 0 ? f.d.height : mountMm;
    luminaires.push({ photo, p: [f.x / k, f.y / k, h], aim: [0, 0, -1], rot: Number.isFinite(f.d.aim) ? f.d.aim : 0, id: f.id });
  }
  return { luminaires, skipped };
}

Lux written at the grid points

64-bit

The text objects that show the illuminance at each grid point in the drawing.

text = round(E); position = grid point × k

The value is rounded to a whole lux when written, so the drawing carries fewer digits than the result it came from. With more than 2000 grid points only every n-th point gets a text; the others are not shown.

  • addons/lighting/lib/lux.js
  • lines 53 to 62
  • CadCraft 0.8.2
/** The value (lux, whole numbers) written at each grid point on `layer`, in drawing units (k per mm). */
export function luxEntities(res, k = 1, { layer = 'LX-LUX', textH = 150, max = 2000 } = {}) {
  const out = [];
  const step = Math.max(1, Math.ceil(res.points.length / max));
  res.points.forEach((p, i) => {
    if (i % step) return;
    out.push({ type: 'text', layer, color: null, x: p[0] * k, y: p[1] * k, h: textH * k, rot: 0, s: String(Math.round(res.values[i])), ha: 'center', va: 'middle', wf: 1 });
  });
  return out;
}

In detail

Method
position in mm = drawing coordinate ÷ k (drawing units per mm). Text value = round(lux).
Number types
64-bit numbers; the written value is a whole number as text.
Tolerances
Lux rounded to 1. At most 2000 values are written by default: every ⌈points ÷ 2000⌉-th point.
Limits
A fixture with no height uses the plot's mounting height, 6000 mm unless set. The engine computes direct illuminance only.

Approach: 64-bit, stated limit

The arithmetic is 64-bit, but the method or the data sets the accuracy: a solver tolerance, a mesh, a step size, a datum shift, a table. The limit is stated where the result is shown.

Every policy that takes this approach