==== Rotate ====
Shapes can be rotated by any given angle about the X, Y, and Z axis. The ''angles'' can be specified as either positive or negative values, in RADIANS.
//[[http://www.mathsisfun.com/geometry/rotation.html|Learn about rotation at MathIsFun.com]]//
Defaults:
* angles : [0, 0, 0]
const { cuboid } = require('@jscad/modeling').primitives
const { rotate } = require('@jscad/modeling').transforms
const myshape = cuboid({size: [5, 20, 5]})
const newshape = rotate([(Math.PI * 2 / 4), (Math.PI * 2 / 24), (Math.PI * 2 / 12)], myshape)
In addition, there are simple versions of the same function for rotating about a single axis.
const { cuboid } = require('@jscad/modeling').primitives
const { rotateX,rotateY,rotateZ } = require('@jscad/modeling').transforms
const myshape = cuboid({size: [5, 20, 5]})
let newshape = rotateX((Math.PI * 2 / 4), myshape)
newshape = rotateY((Math.PI * 2 / 24), newshape)
newshape = rotateZ((Math.PI * 2 / 12), newshape)
There is a [[en:jscad_design_math|utility function]] to convert DEGREE to RADIAN values.
const { cuboid } = require('@jscad/modeling').primitives
const { rotateX,rotate } = require('@jscad/modeling').transforms
const { degToRad } = require('@jscad/modeling').utils
const myshape = cuboid({size: [5, 20, 5]})
const newshape = rotate([degToRad(90), degToRad(15), degToRad(30)], myshape)
const newshape = rotateX(degToRad(90), myshape)