The cutting plane of the live section view: its normal and position, and the range of its slider.
How the precision is kept
The plane only decides what the 3-D view cuts away; it does not change the model. The arithmetic in this file is 64-bit, and the plane is then handed to the view.
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.
The lowest and highest value of n·p over the model's box, the two ends of the section slider.
lo, hi = min, max of n · p over the 8 box corners
Eight 64-bit dot products; the corner is chosen with bit tests on the loop counter. The result sets a view control only.
section.js
lines 19 to 27
PartCraft 0.8.1
/** [lo, hi] of n·p over the 8 corners of box { min: [x,y,z], max: [x,y,z] }. */
export function sectionRange(box, n) {
let lo = Infinity, hi = -Infinity;
for (let k = 0; k < 8; k++) {
const p = [k & 1 ? box.max[0] : box.min[0], k & 2 ? box.max[1] : box.min[1], k & 4 ? box.max[2] : box.min[2]];
const d = dot(n, p); if (d < lo) lo = d; if (d > hi) hi = d;
}
return [lo, hi];
}
Section through a picked face
32-bit, display only
The cutting plane through a flat face, placed by the instance matrix of an assembly.
n = unit(M · n_face); c = n · (M · o_face)
The normal is multiplied by the matrix itself and normalized, which is correct for rotations and uniform scale only (the code comment says so). The plane is used to cut the view only.
section.js
lines 32 to 41
PartCraft 0.8.1
/**
* A flat face's plane as a section: n = the face's outward normal (placed), c = n·(a point of the face). Cutting away
* n·p > c removes what lies outside the face, so the cut starts flush with it. Directions go through the matrix's
* inverse transpose (exact for rotations and uniform scale, which is all an assembly placement holds).
*/
export function faceSection(face, M = null) {
if (!face || face.type !== 'plane' || !face.n || !face.o) throw new Error(t('section.need_flat'));
const n = unit(xf(M, face.n, 0)), o = xf(M, face.o, 1);
return { n, c: dot(n, o) };
}
In detail
Method
Dot products over the eight corners of the model's box; a picked flat face's normal and point placed by a 4 × 4 matrix.
Number types
64-bit numbers in plain arrays.
Tolerances
A direction shorter than 1e-12 is refused.
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.