Resources Numerical accuracy
Calculations
Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.
Calculations
-
Drawing coordinates to scene coordinates
The positions sent to the GPU: centered on the drawing and scaled to about 100 units across.
scene = (p − center) × 100 ÷ largest extent
DWG and DXF views on screen dwg-view3d.js32-bit, display only- BimCraft
-
Nearest line to the pointer
The distance in pixels from the pointer to a line, for picking.
t = clamp(((p − a) · (b − a)) ÷ |b − a|², 0, 1); d = |a + t·(b − a) − p|
DWG and DXF views on screen dwg-view3d.js32-bit, display only- BimCraft
-
Zoom to the drawing
The zoom and center that show the whole drawing or sheet.
zoom = min(W ÷ w, H ÷ h) × 0.92; center = middle of the bounds
DWG and DXF views on screen dwg-view.js32-bit, display only- BimCraft
-
Feature edges of one element
The edges of an element where its faces meet at more than the feature angle, plus its free edges.
edge drawn when n₁ · n₂ ≤ cos(angle), or when only one triangle uses it
Element outlines in the IFC view ifc-vis.js32-bit, display only- BimCraft
-
Edge segments of a batch
Collects every element's edges into one array of line segments with a run per element.
Element outlines in the IFC view ifc-vis.js32-bit, display only- BimCraft
-
Cutting a story's elements
The cut segments of every element the cut plane passes through, and the edges of what lies below or above.
Plan view of elements drawn from their mesh model-plan.js32-bit, display only- BimCraft
-
Cutting one triangle
The segment where a triangle crosses the cut plane.
t = (h − zᵢ) ÷ (zⱼ − zᵢ); point = pᵢ + t (pⱼ − pᵢ)
Plan view of elements drawn from their mesh model-plan.js32-bit, display only- BimCraft
-
Joining cut segments into loops
Closed outlines from the cut segments, for the fill.
Plan view of elements drawn from their mesh model-plan.js32-bit, display only- BimCraft
-
Sun direction for a rendering
The direction to the sun in the 3D view's axes.
model = east × dₓ + north × d_y, with d_z kept; view = (mₓ, m_z, −m_y), normalized
Rendering: sun direction, lamps and painted faces render-bim.js32-bit, display only- BimCraft
-
Lamps from light fixtures
A lamp for each light fixture: where it is, how bright and how wide.
lumens = stored value, else watts × 80, else 800; position = middle of the fixture's box, just under it
Rendering: sun direction, lamps and painted faces render-bim.js32-bit, display only- BimCraft
-
Which side of an element a face is
Names the axis of the element's placement that a face normal runs along, to pick the material painted on that side.
axis = the placement column with the largest |n · column|
Rendering: sun direction, lamps and painted faces paint-bim.js32-bit, display only- BimCraft
-
Planes of a section cell
The outward normal and a point of each plane that bounds a section cell, with tilted faces and extra planes.
n = unit(n₀ + tan a × e_u + tan b × e_v); extra: n = (cos el cos az, cos el sin az, sin el)
Section volumes in the 3D view section-volume.js32-bit, display only- BimCraft
-
Corners and edges of a section cell
The corners, faces and edges of the convex cell its planes bound, drawn as the cell's frame.
corner = (d_a (n_b × n_c) + d_b (n_c × n_a) + d_c (n_a × n_b)) ÷ (n_a · (n_b × n_c))
Section volumes in the 3D view section-volume.js32-bit, display only- BimCraft
-
A plane through a point as an extra plane
Turns a plane given by a normal and a point into the azimuth, elevation and offset a section cell keeps.
az = atan2(u_y, u_x); el = asin(clamp(u_z, −1, 1)); off = u · (p − center)
Section volumes in the 3D view section-volume.js32-bit, display only- BimCraft
-
Clipping planes of a section box
Turns each section cell's planes into the viewer's clipping planes and draws the cell's frame a hair inside it.
viewer normal = turn(−n_x, −n_z, n_y); frame inset = Σ sizes × 1e-5 + 1e-4
3D view drawing viewer3d.js32-bit, display only- BimCraft
-
Section frame turned with the building
Rotates a viewer point about the vertical through the model's center into the section frame.
x′ = c_x + x cos a + z sin a; z′ = c_z − x sin a + z cos a
3D view drawing viewer3d.js32-bit, display only- BimCraft
-
Model bounds in the section frame
The bounds of every drawn vertex in the turned section frame.
box = min and max of turned vertex positions
3D view drawing viewer3d.js32-bit, display only- BimCraft
-
Child boxes of a node
Stores the boxes of a node's four children as 8-bit offsets from the node's corner.
scale = 2^e, the smallest with 255 × 2^e ≥ extent; lo = floor((box − origin) ÷ scale), hi = ceil(…)
Ray casting for rendering and the render bench compute/bvh-wide.js32-bit, display only- BimCraft
- ModelCraft
-
Ray through the hierarchy
Walks the hierarchy along a ray and returns the nearest hit distance.
per axis: t = (box − origin) × (1 ÷ direction); hit if max of the near values ≤ min of the far values × (1 + 4×10⁻⁷)
Ray casting for rendering and the render bench compute/bvh-wide.js32-bit, display only- BimCraft
- ModelCraft
-
Preview shading of a tile
Shades each pixel of a tile from the surface it sees, lit from the eye.
value = 0.08 + 0.72 × |n · d| ÷ |n|
Ray casting for rendering and the render bench compute/preview-kernel.js32-bit, display only- BimCraft
- ModelCraft
-
Camera rays for one tile
Casts the camera rays of a tile and counts the rays, the hits and the sum of the hit distances, for timing.
direction = normalize(camera matrix · ((2 (x + jitter) ÷ W − 1) ÷ f_x, (1 − 2 (y + jitter) ÷ H) ÷ f_y, −1))
Ray casting for rendering and the render bench compute/raycast-job.js32-bit, display only- BimCraft
- ModelCraft
-
Triangles in world space
Every mesh triangle moved by its placement, cut by the section planes and stored for the kernels.
Path tracer scene, light and sky buffers render/pt-pack.js32-bit, display only- BimCraft
- ModelCraft
-
Derived material values
The relative refractive index, coat Fresnel average, extinction and dispersion term of a material record.
μt = −ln(color) ÷ depth; B = (η − 1) ÷ ((abbe ÷ scale) × (1 ÷ 0.4861² − 1 ÷ 0.6563²))
Path tracer scene, light and sky buffers render/pt-pack.js32-bit, display only- BimCraft
- ModelCraft
-
Physical sky color
The sky's color in a direction for a sun position and haze.
Path tracer scene, light and sky buffers render/pt-sky.js32-bit, display only- BimCraft
- ModelCraft
-
Light profile grid
A lamp's IES light distribution as a grid of direction multipliers.
multiplier = candela(θ, φ) × 4π ÷ flux
Path tracer scene, light and sky buffers render/pt-ies.js32-bit, display only- BimCraft
- ModelCraft
-
Adding samples to a pixel
The sum of sample colors and the sample count of every pixel in the reference tracer.
Path tracer kernels render/pt-ref.js32-bit, display only- BimCraft
- ModelCraft
-
Fresnel reflectance of glass
The share of light a clear surface reflects at an angle.
F = (r∥² + r⊥²) ÷ 2
Path tracer kernels render/pt-ggx.js32-bit, display only- BimCraft
- ModelCraft
-
Sample position
The random-like number in [0, 1) used for one dimension of one sample of one pixel.
Path tracer kernels render/pt-sampler.js32-bit, display only- BimCraft
- ModelCraft
-
Adaptive sampling test
Decides when a pixel has had enough samples.
v = max(0, (S₂ − S₁² ÷ J) ÷ (J − 1)); stop when √(v ÷ J) ≤ noise × (μ + 0.02)
Path tracer kernels render/pt-adapt.js32-bit, display only- BimCraft
- ModelCraft
-
Lamp strength
A lamp's lumens turned into the strength the renderers use.
point or spot: Φ ÷ 4π × 0.02; panel: Φ ÷ π × 0.02
Fast render lights and texture placement render/looks.js32-bit, display only- BimCraft
- ModelCraft
-
Sun direction for a pass
A direction inside a small cone around the sun, one per render pass, for soft shadow edges.
r = √h₅ × tan(degrees × π ÷ 180); a = 2π h₇
Fast render lights and texture placement render/looks.js32-bit, display only- BimCraft
- ModelCraft
-
Texture coordinates of a point
Where a point of a surface falls on its material's texture, in meters along and up the surface.
u = p · (up × n) ÷ |up × n|; v = p · (n × u axis)
Fast render lights and texture placement render/materials.js32-bit, display only- BimCraft
- ModelCraft
-
Camera jitter per pass
Moves the camera by less than a pixel each pass so that the sum of passes is anti-aliased.
j_x = (h₂(i) − ½) × 2 ÷ w; rows 0 and 1 of the projection += j × row 3
Rendered pictures render/render-core.js32-bit, display only- BimCraft
- ModelCraft
-
Section cut for the path tracer
Clips every triangle of the scene against the section planes before the picture is traced.
new corner = a + (b − a) × d_a ÷ (d_a − d_b)
Rendered pictures render/render-pt.js32-bit, display only- BimCraft
- ModelCraft
-
Tiling fractal noise
The noise value behind the library's brick, wood, stone and concrete textures.
Σ ampₒ × noise(u fₒ, v fₒ) ÷ Σ ampₒ, f doubling and amp × gain per octave
Rendered pictures render/textures.js32-bit, display only- BimCraft
- ModelCraft
-
Normal map bytes
Turns a baked material's normal layer into the texture three.js reads.
x = (byte − 128) ÷ 127; z = √(1 − x² − y²); out = (x ÷ 2 + ½) × 255
Rendered pictures render/three-mats.js32-bit, display only- BimCraft
- ModelCraft
-
Probe light as spherical harmonics
Sums a small traced panorama into the four coefficients per color the view shades with.
c = Σ L × Y × dΩ, dΩ = (2π ÷ w)(π ÷ h) sin θ
Real-time view rt/rt-probes.js32-bit, display only- BimCraft
- ModelCraft
-
Cube faces to a 360° picture
Builds the equirectangular panorama from six rendered faces.
direction from (longitude, latitude); face = largest d·a; color = bilinear mix of four pixels
Real-time view rt/rt-pano.js32-bit, display only- BimCraft
- ModelCraft
-
Display chain for one pixel
Turns a linear color into the color shown: white balance, exposure, highlight knee, contrast, view transform.
c ← max(0, WB c) × 2^stops; c ← 0.18 × (c ÷ 0.18)^(1 + contrast)
Real-time view rt/rt-look.js32-bit, display only- BimCraft
- ModelCraft
-
Standing and falling in walk mode
Keeps the walker's eye at eye height above the floor below, stepping up or falling as the floor changes.
v ← v − 9.81 Δt; height ← max(floor + eye height, height + v Δt)
Real-time view rt/rt-walk.js32-bit, display only- BimCraft
- ModelCraft
-
Values to texture bytes
Stores a value from 0 to 1, or a normal component from −1 to 1, as one byte of a texture layer.
byte = ⌊255 x + ½⌋; normal byte = ⌊127 x + 128.5⌋
Material graphs baked to textures shading/bake.js32-bit, display only- BimCraft
- ModelCraft
-
Tiling value noise
The smooth noise that procedural textures are built from.
a + (b − a) f_x + (c − a) f_y + (a − b − c + d) f_x f_y, f = t² (3 − 2t)
Material graphs baked to textures shading/lib.js32-bit, display only- BimCraft
- ModelCraft
-
Ambient occlusion of a texel
The share of directions above a surface point that are not blocked nearby.
open ÷ rays, directions (√u₁ cos 2πu₂, √u₁ sin 2πu₂, √(1 − u₁)) about the normal
Material graphs baked to textures shading/texbake-job.js32-bit, display only- BimCraft
- ModelCraft
-
Decal geometry
The triangles under a decal, clipped to its box and lifted off the surface.
corner = o + x u + y v + z n + 0.0005 × face normal
Material graphs baked to textures shading/decal.js32-bit, display only- BimCraft
- ModelCraft
-
Affine through three points
The affine transform that carries three source points onto three destination points.
det = (u₁ − u₀)(v₂ − v₀) − (u₂ − u₀)(v₁ − v₀); a = ((x₁ − x₀)(v₂ − v₀) − (x₂ − x₀)(v₁ − v₀)) ÷ det
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Cells of a warped picture
The cells a picture is cut into so that each can be drawn with one affine transform.
split while max |affine(p) − exact(p)| > tol over the fourth corner, the middle and the four edge midpoints
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Tile level for the screen
Which level of a tile grid is drawn at the current zoom.
the coarsest level with res ≤ 1.5 × screen resolution
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Warp plan for a picture or tile
How finely a map image is cut into patches so that it lands in the right place on screen.
tolerance = 0.25 ÷ zoom project units, rounded to a half power of 2
Map layers under the drawing maplayers.js32-bit, display only- CadCraft
- BimCraft
-
Drawing the patches
Each patch of a map image drawn on the canvas.
Map layers under the drawing maplayers.js32-bit, display only- CadCraft
- BimCraft
-
Drawing coordinates to screen position
Where a drawing point is on screen, in CSS pixels of the active pane.
sx = (x − cx)·zoom + w ÷ 2; sy = h ÷ 2 − (y − cy)·zoom (with a turn: the difference is rotated first)
2D drawing on screen view.js32-bit, display only- CadCraft
A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.