meta data for this page
  •  
Your (re)login has failed.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:design_guide_rotate [2020/12/01 00:05]
JSCAD Editor
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 angle about the X, Y, and Z axis. The angles can be specified as either positive or negative values, in RADIANS.+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]]// //[[http://www.mathsisfun.com/geometry/rotation.html|Learn about rotation at MathIsFun.com]]//
Line 9: Line 9:
  
 <code javascript> <code javascript>
-let myshape = cuboid({size: [5, 20, 5]}) +const { cuboid } = require('@jscad/modeling').primitives 
-let newshape = rotate([(PI * 2 / 4), (PI * 2 / 24), (PI * 2 / 12)], myshape)+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) 
 +</code> 
 + 
 +In addition, there are simple versions of the same function for rotating about a single axis. 
 + 
 +<code javascript> 
 +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) 
 +</code> 
 + 
 +There is a [[en:jscad_design_math|utility function]] to convert DEGREE to RADIAN values. 
 + 
 +<code javascript> 
 +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)
 </code> </code>
  
-//Note: There is a utility function to convert RADIAN to DEGREE values.//