Part and assembly mass in the bill of materials, measure panel and assistant
Mass, volume, area, center and inertia as the bill of materials, the measure panel and the assistant report them.
How the precision is kept
With the mesh kernel the part mesh is a Float32Array of positions copied from the kernel's output, so volume, area, center and inertia are computed in 64-bit arithmetic from 32-bit vertex positions. With the exact kernel the measure panel asks the exact worker instead. The report files round the numbers to a fixed number of decimals.
Open item. Compute the mesh-kernel mass properties from the 64-bit vertex data of the kernel (or use the exact kernel) instead of the Float32Array copy.
Calculations under this policy
5 calculations in 3 source files. 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.
bom.jsPartCraft 0.8.164-bit2 calculationsReviewed
TestsNone found by the review
Mass from volume and density
64-bit
The mass of a part in grams.
m = V × ρ ÷ 1000
One multiply and one divide in 64-bit numbers; the volume passed in is the build's reported volume, whose own precision is set in the kernel.
bom.js
lines 63 to 64
PartCraft 0.8.1
/** Grams from mm³ and g/cm³. */
export const massOf = (volume, density) => volume * density / 1000;
Rounding of the exported bill
64-bit
The numbers written into the bill of materials CSV.
value = round to 3 decimals
Volume and masses are rounded to 3 decimals with toFixed(3) in the written file. The total mass is summed from the unrounded row masses first and then rounded.
agents.jsPartCraft 0.8.1 32-bit in part1 calculationReviewed
TestsNone found by the review
Mass properties reported to the assistant
32-bit in part
Volume, area, center, mass and inertia of the built solid.
mass = V × ρ ÷ 1000; inertia = tensor × ρ ÷ 1000
meshMass reads the 32-bit positions of the mesh kernel. The code names the density as g/cm³ ÷ 1000 (a comment says g/mm³), and each reported value is rounded to 6 decimals with Math.round(v × 1e6) ÷ 1e6.
agents.js
lines 133 to 145
PartCraft 0.8.1
/** Mass properties of the built solid: volume, area, centre, inertia; mass when the part has a material. */
export function massOf(part, regen) {
if (!regen?.mesh) throw new Error('The part has no solid yet.');
const m = meshMass(regen.mesh);
const rho = part.material && Number.isFinite(part.material.density) && part.material.density > 0 ? part.material.density / 1000 : null; // g/cm³ → g/mm³
const k = rho ?? 1;
return {
volume: r6(m.volume), volumeUnit: 'mm³', area: r6(m.area), areaUnit: 'mm²', centre: m.centre.map(r6), axes: 'model axes, Y up',
material: part.material ? part.material.name : null, mass: rho ? r6(m.volume * rho) : null, massUnit: 'g',
inertia: m.tensor.map((row) => row.map((v) => r6(v * k))), inertiaUnit: rho ? 'g·mm² (about the centre)' : 'mm⁵ (density 1; the part has no material)',
note: 'From the triangle mesh (the mesh kernel): curved faces are facets, so the volume is a little under a true curved solid\'s.',
};
}
measure-ui.jsPartCraft 0.8.1 32-bit in part2 calculationsReviewed
TestsNone found by the review
Mass properties in the measure panel
32-bit in part
Where the measure panel gets a body's mass properties, exact or from the mesh.
With the exact kernel the properties come from the exact worker. Otherwise meshMass runs on the mesh from the kernel, whose positions are 32-bit. The panel then places the result with the part's matrix and density.
measure-ui.js
lines 123 to 126
PartCraft 0.8.1
async function propsOf(tg) {
if (ctx.useExact() && tg.build.exact) return ctx.exact.call('measureMass', { part: tg.part });
return ME.meshMass(tg.build.mesh);
}
Number format in the measure panel
64-bit
Rounds a measure value to a number of decimals for the panel.
toFixed(dp); |v| < 1e-12 shown as 0
The default is 4 decimals. Values with absolute value under 1e-12 are shown as 0, which hides tiny values, and trailing zeros are dropped by the Number round trip.
Mass = volume × density ÷ 1000 (mm³ and g/cm³ to g). Mesh volume, centroid and inertia by the divergence theorem over triangles (measure.js meshMass).
Number types
mesh.positions is a Float32Array (kernel.js getMesh copy). The sums in meshMass are 64-bit. Densities and volumes in the bill are 64-bit numbers.
Tolerances
Bill CSV values are rounded to 3 decimals; the assistant's values are rounded to 6 decimals; the measure panel shows 3 or 4 decimals. A value under 1e-12 in the panel is shown as 0.
Limits
A curved face is faceted in the mesh kernel, so the assistant states the volume is a little under a true curved solid's.
Approach: 32-bit step, flagged
One step stores or exchanges 32-bit values that reach a number a person reads. It is listed here with its open item, and the step is either moved to 64-bit or the app will warn where the number is read.