meta data for this page
Measurements
Sometimes the measurements of a shape can assist when creating a design. This is especially true for shapes imported from external formats.
const { measureArea, measureBoundingBox, measureVolume } = require('@jscad/modeling').measurements
Area
Measuring the area of a shape is possible, for both 2D and 3D shapes.
let area = measureArea(sphere())
Note: The area for a path is always zero(0) as paths are infinitely thin.
In addition, the total (aggregate) area for the given geometries can be measured.
let totalArea = measureAggregateArea(sphere(),cube())
Note: This measurement will not account for overlapping geometry.
Bounding Box
Measuring the bounding box (min and max bounds) of a shape is possible.
The measureBoundingBox function can be used to retrieve the bounding box of an object, returning an array with two points specifying the minimum and maximum coordinates, i.e. X, Y, Z values.
let bounds = measureBoundingBox(sphere())
In addition, the total (aggregate) bounding box for the given geometries can be measured.
let totalBounds = measureAggregateBoundingBox(sphere(),cube())
Bounding Sphere
Measuring the (approximate) bounding sphere of a shape is possible.
let bounds = measureBoundingSphere(cube())
Center
Measuring the center of a shape is possible.
let center = measureCenter(sphere())
Note: This is equivalent to the center of the bounding box.
Center of Mass
Measuring the center of mass of a shape is possible.
let center = measureCenterOfMass(sphere())
Note: The center of mass for a path is always zero(0) as paths are infinitely thin.
Dimensions
Measuring the dimensions of a shape is possible, i.e. width, depth, and height of a shape.
let dimensions = measureDimensions(sphere())
Note: This is the equivalent width, depth, height of the bounding box.
Epsilon
Measuring the epsilon of shapes is possible. Epsilon values are used in various functions to determine minimum distances between points, planes, etc.
let epsilon = measureEpsilon(sphere())
In addition, the combined epsilon for a group geometries can be measured.
let groupEpsilon = measureAggregateEpsilon(sphere(),cube())
Volume
Measuring the volume of a shape is possible.
let volume = measureVolume(sphere())
Note: The volume of 2D shapes is always zero(0).
In addition, the total (aggregate) volume for the given geometries can be measured.
let totalVolume = measureAggregateVolume(sphere(),cube())
Note: This measurement will not account for overlapping geometry.