utils
modeling/utils
Utility functions of various sorts, including conversions from different angular measures.
Example
const { areAllShapesTheSameType, degToRad, radiusToSegments, radToDeg } = require('@jscad/modeling').utils
modeling/utils.areAllShapesTheSameType(shapes)
Kind: static method of modeling/utils
Returns: Boolean - true if the given shapes are of the same type
| Param | Type | Description |
|---|---|---|
| shapes | Array | list of shapes to compare |
modeling/utils.degToRad(degrees)
Convert the given angle (degrees) to radians.
Kind: static method of modeling/utils
Returns: Number - angle in radians
| Param | Type | Description |
|---|---|---|
| degrees | Number | angle in degrees |
modeling/utils.flatten(arr)
Flatten the given list of arguments into a single flat array. The arguments can be composed of multiple depths of objects and arrays.
Kind: static method of modeling/utils
Returns: Array - a flat list of arguments
| Param | Type | Description |
|---|---|---|
| arr | Array | list of arguments |
modeling/utils.fnNumberSort()
Kind: static method of modeling/utils
modeling/utils.insertSorted()
Insert the given element into the given array using the compareFunction.
Kind: static method of modeling/utils
modeling/utils.padArrayToLength(anArray, padding, targetLength)
Build an array of at minimum a specified length from an existing array and a padding value. IF the array is already larger than the target length, it will not be shortened.
Kind: static method of modeling/utils
Returns: Array - an array of at least 'targetLength' length
| Param | Type | Description |
|---|---|---|
| anArray | Array | the source array to copy into the result. |
| padding | * | the value to add to the new array to reach the desired length. |
| targetLength | Number | The desired length of the return array. |
modeling/utils.radiusToSegments(radius, minimumLength, minimumAngle)
Calculate the number of segments from the given radius based on minimum length or angle.
Kind: static method of modeling/utils
Returns: Number - number of segments to complete the radius
| Param | Type | Description |
|---|---|---|
| radius | Number | radius of the requested shape |
| minimumLength | Number | minimum length of segments; length > 0 |
| minimumAngle | Number | minimum angle (radians) between segments; 0 > angle < TAU |
modeling/utils.radToDeg(radians)
Convert the given angle (radians) to degrees.
Kind: static method of modeling/utils
Returns: Number - angle in degrees
| Param | Type | Description |
|---|---|---|
| radians | Number | angle in radians |