meta data for this page
  •  

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_transforms [2020/12/01 00:36]
JSCAD Editor
en:design_guide_transforms [2021/05/12 08:28] (current)
JSCAD Editor
Line 4: Line 4:
  
 <code javascript> <code javascript>
-let circleA = circle({radius: 5}) +const myshape = circle({radius: 5}) 
-let circleB = scale([5, 10], circleA) // a new cicle, scaled as requested+const newshape = scale([5, 10], circleA) // a new cicle, scaled as requested
 </code> </code>
  
Line 11: Line 11:
  
 <code javascript> <code javascript>
-let circleA = circle({radius: 5}) +let myshape = circle({radius: 5}) 
-circleA = scale([5,10], circleA) // a new circle, scaled as requested, reassigned to the original+myshape = scale([5, 10], myshape) // a new circle, scaled as requested, reassigned to the original
 </code> </code>
  
Line 18: Line 18:
  
 <code javascript> <code javascript>
-let circleA = scale([5, 10]). circle({radius: 5})) // a new circle, and scaled as requested+let myshape = scale([5, 10]). circle({radius: 5})) // a new circle, and scaled as requested
 </code> </code>
  
Line 24: Line 24:
  
 <code javascript> <code javascript>
-// rotate the circle about the X axis by 45 degrees +let myshape = scale([5, 10]). circle({radius: 5})) 
-// and translate the circle up the Z axis 10 units +myshape = translate([0, 0, 10]), rotateX(45, myshape))
-// and assign the result to circleB +
-let circleB = translate([0, 0, 10]), rotateX(45, circleA))+
 </code> </code>
  
-The original shape can be transformed any number of times. For example, the same cylinder can be rotated, making copies of the cylinders, and then unioned together. This is a common pattern when creating complex designs.+The original shape can be transformed any number of times. For example, the a single cylinder can be rotated and translated to make multiple copies of the original. And then, the set of cylinders can be combined together using union. This is a common pattern when creating complex designs.
  
-==== Orientation ====+The transforms return a single shape or an array of shapes depending on the given shapes.
  
-The standard for all 3D systems todayincluding graphics cardsdesign toolsetc. is orientating shapes using the right-hand rule. JSCAD follows the same rules internallyand produces shapesapplies transformsetc. using the right-hand rule of orientation.+<code javascript> 
 +const newshape = align({modes: ['none''center''none']}oldshape)  /* Returns a single shape */ 
 +const newshapes = align({modes: ['min''center''none']alignTo: [10, null, 10], grouped: true }, oldshape, [oldshape0, oldshape1])  /* Returns an array of new shapes*/ 
 +</code>
  
-//[[https://en.wikipedia.org/wiki/Right-hand_rule|Learn about the right-hand rule at Wikipedia.org]]//+==== Orientation ==== 
 + 
 +The standard for all 3D systems today, including graphics cards, design tools, etcis orientating shapes using the right-hand rule. JSCAD follows the same rules internally, and produces shapes, applies transforms, etc. using the right-hand rule of orientationSee [[en:math_guide_orientation|Orientation]] for more information.
  
 {{page>design_guide_rotate}} {{page>design_guide_rotate}}
Line 43: Line 46:
  
 {{page>design_guide_translate}} {{page>design_guide_translate}}
 +
 +{{page>design_guide_align}}
  
 {{page>design_guide_center}} {{page>design_guide_center}}