meta data for this page
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
en:design_guide_rotate [2020/11/28 02:56] JSCAD Editor created |
en:design_guide_rotate [2022/04/16 04:23] (current) rozek included "require" statements, corrected mistakes |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Rotate ==== | ==== Rotate ==== | ||
| - | Shapes can be rotated by any given degree | + | Shapes can be rotated by any given angle about the X, Y, and Z axis. The '' |
| // | // | ||
| Defaults: | Defaults: | ||
| - | * degree | + | * angles |
| <code javascript> | <code javascript> | ||
| - | let obj = cube([5, | + | const { cuboid } = require(' |
| - | obj = rotate([90,15,30],obj) | + | const { rotate } = require(' |
| - | obj = rotate(90,[1,0.25,0.5],obj) | + | |
| + | const myshape | ||
| + | const newshape | ||
| + | </ | ||
| + | |||
| + | In addition, there are simple versions of the same function for rotating about a single axis. | ||
| + | |||
| + | <code javascript> | ||
| + | const { cuboid } = require(' | ||
| + | const { rotateX,rotateY,rotateZ } = require(' | ||
| + | |||
| + | const myshape = cuboid({size: | ||
| + | let newshape = rotateX((Math.PI * 2 / 4), myshape) | ||
| + | newshape = rotateY((Math.PI * 2 / 24), newshape) | ||
| + | newshape = rotateZ((Math.PI * 2 / 12), newshape) | ||
| </ | </ | ||
| - | The CSG library functions can also be used. //NOTE: Deprecated in the V2 API// | + | There is a [[en:jscad_design_math|utility function]] to convert DEGREE to RADIAN values. |
| <code javascript> | <code javascript> | ||
| - | obj.rotateX(90); | + | const { cuboid } = require(' |
| - | obj.rotateY(45); | + | const { rotateX, |
| - | obj.rotateZ(30); | + | const { degToRad } = require(' |
| - | obj.rotate(rotationCenter, rotationAxis, degrees) | + | const myshape = cuboid({size: [5, 20, 5]}) |
| - | obj.rotateEulerAngles(alpha, beta, gamma, position) | + | const newshape = rotate([degToRad(90), degToRad(15), degToRad(30)], |
| + | const newshape = rotateX(degToRad(90), myshape) | ||
| </ | </ | ||