•

This is an old revision of the document!

## Conversions

### Conversions between Degrees and Radians

Convert the given angle (degrees) to radians.

`let radians = degToRad(90) // PI / 2 radians`

Convert the given angle (radians) to degrees.

`let degrees = radToDeg(Math.PI / 2) // 90 degrees`

### Conversions of Radius to Segments

Calculate the number of segments to complete the given radius (full rotation), using either minimum length or minimum angle.

There are various round shapes that support the 'segments' option. However, designs may require a specific 'precision' for specific shapes. For example, an arc as part of a path requires specific length segments for proper laser cutting.

This function can be used to calculate the appropriate number of segments based on the radius of the rounded shape.

Using the above example, the arc has a radius of 3.5 mm (units are typically mm). The laser printer requires 0.1 mm segments or more while moving. The segments can be calculated, and supplied when creating the arc.

```let segments = radiusToSegments(3.5, 0.1, 0) /* use minimum length */
let segments = radiusToSegments(3.5, 0, Math.PI * 2 / 300) /* use minimum angle */ ```

NOTE: The number of segments can become large depending on the 'precision' requirements. Testing designs with a lower number of segments is recommended.

## Orientation

All the internal calculations of JSCAD (and other included libraries) are based on the 'right-hand' rule. (For more information see discussions here and here.)

This results in the following orientation of the three-dimensional coordinate system, i.e. orientation of X, Y, and Z axis.

• Positive X points to the right
• Positive Y points to the back
• Positive Z points to the top

This also means that positive rotations are

• From positive X to positive Y about the Z axis
• From positive Y to positive Z about the X axis
• From positive Z to positive X about the Y axis

It may take some time to understand well, and can be visualized by rotating shapes by both positive and negative angles.