Skip to content

Commit

Permalink
docs(modeling): corrections and improvements to doc strings and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
z3dev committed Dec 28, 2024
1 parent c6d9d3a commit a1beedb
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 28 deletions.
1 change: 0 additions & 1 deletion packages/modeling/src/curves/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @module modeling/curves
* @example
* const { bezier } = require('@jscad/modeling').curves
*/
module.exports = {
bezier: require('./bezier')
Expand Down
3 changes: 1 addition & 2 deletions packages/modeling/src/maths/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* @see Most computations are based upon the glMatrix library (glmatrix.net)
* @module modeling/maths
* @example
* const { constants, line2, mat4, vec2, vec3 } = require('@jscad/modeling').maths
* const { constants, line2, line3, mat4, plane, utils, vec2, vec3, vec4 } = require('@jscad/modeling').maths
*/
module.exports = {
constants: require('./constants'),
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/booleans/intersect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const intersectGeom3 = require('./intersectGeom3')
* @alias module:modeling/booleans.intersect
*
* @example
* let myshape = intersect(cube({size: [5,5,5]}), cube({size: [5,5,5], center: [5,5,5]}))
* let myshape = intersect(cube({size: 5}), cube({size: 5, center: [3,3,3]}))
*
* @example
* +-------+
Expand Down
2 changes: 2 additions & 0 deletions packages/modeling/src/operations/booleans/scission.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const scissionGeom3 = require('./scissionGeom3')
/**
* Scission (divide) the given geometry into the component pieces.
*
* NOTE: Currently only 3D geometries are supported.
*
* @param {...Object} objects - list of geometries
* @returns {Array} list of pieces from each geometry
* @alias module:modeling/booleans.scission
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/booleans/subtract.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const subtractGeom3 = require('./subtractGeom3')
* @alias module:modeling/booleans.subtract
*
* @example
* let myshape = subtract(cuboid({size: [5,5,5]}), cuboid({size: [5,5,5], center: [5,5,5]}))
* let myshape = subtract(cuboid({size: 5}), cuboid({size: 5, center: [3,3,3]}))
*
* @example
* +-------+ +-------+
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/booleans/union.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const unionGeom3 = require('./unionGeom3')
* @alias module:modeling/booleans.union
*
* @example
* let myshape = union(cube({size: [5,5,5]}), cube({size: [5,5,5], center: [5,5,5]}))
* let myshape = union(cube({size: 5}), cube({size: 5, center: [3,3,3]}))
*
* @example
* +-------+ +-------+
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/expansions/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const expandPath2 = require('./expandPath2')
* @example
* let newarc = expand({delta: 5, corners: 'edge'}, arc({}))
* let newsquare = expand({delta: 5, corners: 'chamfer'}, square({size: 30}))
* let newsphere = expand({delta: 2, corners: 'round'}, cuboid({size: [20, 25, 5]}))
* let newcuboid = expand({delta: 2, corners: 'round'}, cuboid({size: [20, 25, 5]}))
*/
const expand = (options, ...objects) => {
objects = flatten(objects)
Expand Down
10 changes: 2 additions & 8 deletions packages/modeling/src/operations/extrusions/extrudeHelical.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ const geom2 = require('../../geometries/geom2')
* @alias module:modeling/extrusions.extrudeHelical
*
* @example
* const myshape = extrudeHelical(
* {
* angle: Math.PI * 4,
* pitch: 10,
* segmentsPerRotation: 64
* },
* circle({size: 3, center: [10, 0]})
* )
* const myshape = circle({size: 3, center: [10, 0]}) // position for extrusion about Z
* const mycoil = extrudeHelical({angle: TAU*2, pitch: 10, segmentsPerRotation: 64}, myshape))
*/
const extrudeHelical = (options, geometry) => {
const defaults = {
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/extrusions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* In all cases, the function returns the results, and never changes the original shapes.
* @module modeling/extrusions
* @example
* const { extrudeLinear, extrudeRectangular, extrudeRotate } = require('@jscad/modeling').extrusions
* const { extrudeHelical, extrudeLinear, extrudeRectangular, extrudeRotate, project, slice } = require('@jscad/modeling').extrusions
*/
module.exports = {
extrudeFromSlices: require('./extrudeFromSlices'),
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/hulls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* In all cases, the function returns the results, and never changes the original shapes.
* @module modeling/hulls
* @example
* const { hull, hullChain } = require('@jscad/modeling').hulls
* const { hull, hullChain, hullPoints2, hullPoints3 } = require('@jscad/modeling').hulls
*/
module.exports = {
hull: require('./hull'),
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/modifiers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* In all cases, these functions returns the results, and never changes the original geometry.
* @module modeling/modifiers
* @example
* const { snap } = require('@jscad/modeling').modifiers
* const { generalize, snap, retessellate } = require('@jscad/modeling').modifiers
*/
module.exports = {
generalize: require('./generalize'),
Expand Down
2 changes: 1 addition & 1 deletion packages/modeling/src/operations/modifiers/snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const snapGeom3 = (geometry) => {
}

/**
* Snap the given geometries to the overall precision (epsilon) of the geometry.
* Snap the given geometries to the precision (calculated epsilon) of the geometry.
* @see measurements.measureEpsilon()
* @param {...Object} geometries - the geometries to snap
* @return {Object|Array} the snapped geometry, or a list of snapped geometries
Expand Down
2 changes: 2 additions & 0 deletions packages/modeling/src/primitives/arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const { isGT, isGTE, isNumberArray } = require('./commonChecks')
* @param {Boolean} [options.makeTangent=false] - adds line segments at both ends of the arc to ensure that the gradients at the edges are tangent
* @returns {path2} new 2D path
* @alias module:modeling/primitives.arc
* @example
* let myshape = arc({ center: [-1, -1], radius: 2, endAngle: (TAU / 4)})
*/
const arc = (options) => {
const defaults = {
Expand Down
3 changes: 2 additions & 1 deletion packages/modeling/src/primitives/polyhedron.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { isNumberArray } = require('./commonChecks')

/**
* Construct a polyhedron in three dimensional space from the given set of 3D points and faces.
*
* The faces can define outward or inward facing polygons (orientation).
* However, each face must define a counter clockwise rotation of points which follows the right hand rule.
* @param {Object} options - options for construction
Expand All @@ -18,7 +19,7 @@ const { isNumberArray } = require('./commonChecks')
* @example
* let mypoints = [ [10, 10, 0], [10, -10, 0], [-10, -10, 0], [-10, 10, 0], [0, 0, 10] ]
* let myfaces = [ [0, 1, 4], [1, 2, 4], [2, 3, 4], [3, 0, 4], [1, 0, 3], [2, 1, 3] ]
* let myshape = polyhedron({points: mypoint, faces: myfaces, orientation: 'inward'})
* let myshape = polyhedron({points: mypoints, faces: myfaces, orientation: 'inward'})
*/
const polyhedron = (options) => {
const defaults = {
Expand Down
3 changes: 0 additions & 3 deletions packages/modeling/src/text/vectorChar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ const vectorParams = require('./vectorParams')
*
* @example
* let vectorCharObject = vectorChar()
* or
* let vectorCharObject = vectorChar('A')
* or
* let vectorCharObject = vectorChar({ xOffset: 57 }, 'C')
* or
* let vectorCharObject = vectorChar({ xOffset: 78, input: '!' })
*/
const vectorChar = (options, char) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/modeling/src/text/vectorText.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ const translateLine = (options, line) => {
*
* @example
* let textSegments = vectorText()
* or
* let textSegments = vectorText('OpenJSCAD')
* or
* let textSegments = vectorText({ yOffset: -50 }, 'OpenJSCAD')
* or
* let textSegments = vectorText({ yOffset: -80, input: 'OpenJSCAD' })
*/
const vectorText = (options, text) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/modeling/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Utility functions of various sorts.
* Utility functions of various sorts, including conversions from different angular measures.
* @module modeling/utils
* @example
* const { flatten, insertSorted } = require('@jscad/modeling').utils
* const { areAllShapesTheSameType, degToRad, radiusToSegments, radToDeg } = require('@jscad/modeling').utils
*/
module.exports = {
areAllShapesTheSameType: require('./areAllShapesTheSameType'),
Expand Down

0 comments on commit a1beedb

Please sign in to comment.