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:quick_reference_transforms [2020/12/01 01:41]
JSCAD Editor
en:quick_reference_transforms [2021/04/30 08:23] (current)
JSCAD Editor
Line 5: Line 5:
 <code javascript> <code javascript>
 const { translate, scale, rotateX } = require('@jscad/modeling').transforms const { translate, scale, rotateX } = require('@jscad/modeling').transforms
-</code> 
- 
-The 'transforms' return a single shape or an array of shapes depending on the given shapes. 
- 
-<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> </code>
  
 ^  Transform  ^  Notes  ^ ^  Transform  ^  Notes  ^
-| const newshape = align({modes: ['min', 'center', 'none'], alignTo: [10, null, 10], grouped: true}, oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.align | API documentation]]  | +| const newshape = align({modes: ['min', 'center', 'none'], relativeTo: [10, null, 10], grouped: true}, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.align | API]]  | 
-| const newshape = center({axes: [true, true, false], center: [15, 10, 0]}, oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.center | API documentation]]  | +| const newshape = center({axes: [true, true, false], center: [15, 10, 0]}, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.center | API]]  | 
-| const newshape = centerX(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerX | API]]  | +| const newshape = centerX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerX | API]]  | 
-| const newshape = centerY(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerY | API]]  | +| const newshape = centerY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerY | API]]  | 
-| const newshape = centerZ(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerZ | API]]  | +| const newshape = centerZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerZ | API]]  | 
-| const newshape = mirror({origin: [5, 5, 5], normal: [0, 0, 10]}, oldshape)) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.mirror | API]]  | +| const newshape = mirror({origin: [5, 5, 5], normal: [0, 0, 10]}, oldshape))  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirror | API]]  | 
-| const newshape = mirrorX(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.mirrorX | API]]  | +| const newshape = mirrorX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorX | API]]  | 
-| const newshape = mirrorY(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.mirrorY | API]]  | +| const newshape = mirrorY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorY | API]]  | 
-| const newshape = mirrorZ(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.mirrorZ | API]]  | +| const newshape = mirrorZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorZ | API]]  | 
- +const newshape rotate([Math.PI / 400], oldshape [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotate | API]]  
- +const newshape rotateX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateX | API]]  | 
- +const newshape rotateY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateY | API]]  | 
-^  2D Transformations  ^  3D Transformations  ^ +const newshape rotateZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateZ | API]]  | 
-2Dshape 2Dshape.translate([-2, -2]); | 3Dshape = 3Dshape.translate([1,2,3])| +| const newshape = scale([5010], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scale | API]]  | 
-| 2Dshape = 2Dshape.rotateZ(20); | 3Dshape = 3Dshape.rotateX(90); +const newshape scaleX(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleX | API]]  | 
-::: | 3Dshape 3Dshape.rotateY(-180) | +const newshape scaleY(0.5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleY | API]]  | 
-::: | 3Dshape = 3Dshape.rotateZ(45);  | +const newshape scaleZ(5, oldshape [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleZ | API]]  | 
-2Dshape 2Dshape.rotate(center, axis, degrees) 3Dshape = 3Dshape.rotate(center, axis, degrees);  | +const newshape = transform(mat4.rotateX(Math.PI/4), oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.transform API]]  | 
-2Dshape 2Dshape.rotateEulerAngles(alpha, beta, gamma, position) 3Dshape = 3Dshape.rotateEulerAngles(alpha, beta, gamma, position); +const newshape translate([5010], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translate | API]]  | 
-| 2Dshape = 2Dshape.scale([0.7, 0.9]);  3Dshape 3Dshape.scale([1,2,3]) | +const newshape translateX(5oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateX | API]]  | 
-| 2Dshape = 2Dshape.center([true,true]); **/* center X & Y axis */**  | 3Dshape = 3Dshape.center([true,true,true]); **/* center X & Y & Z axis */**  | +const newshape translateY(0.5oldshape | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateY | API]]  | 
-2Dshape 2Dshape.mirroredX() 3Dshape = 3Dshape.mirroredX();  | +| const newshape translateZ(5oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateZ | API]]  |
-2Dshape 2Dshape.mirroredY();  | 3Dshape = 3Dshape.mirroredY() | +
-::: | 3Dshape = 3Dshape.mirroredZ();  | +
-2Dshape 2Dshape.mirrored(plane)3Dshape = 3Dshape.mirrored(plane);  | +
-2Dshape 2Dshape.transform(matrix);  | 3Dshape = 3Dshape.transform(matrix) | +
-| **/* not supported yet */**  | 3Dshape = 3Dshape.setColor(r,g,b);  **/* a = 1.0 */**  | +
-| ::: | 3Dshape = 3Dshape.setColor(r,g,b,a);  | +
-::: | 3Dshape 3Dshape.setColor([r,g,b]) **/* a = 1.0 */**  | +
-| ::: | 3Dshape = 3Dshape.setColor([r,g,b,a]);  | +
-2Dshape 2Dshape.expand(0.28); **/* radius, resolution */**  3Dshape = 3Dshape.expand(0.2, 8); **/* radius, resolution */**  | +
-2Dshape 2Dshape.contract(0.28); **/* radius, resolution */**  3Dshape 3Dshape.contract(0.28); **/* radius, resolution */**  | +
- +
-//Note: Shape transformations can be chained togetherExample://+
  
-**var 3Dshape = CSG.cube().rotate(45).translate([20,0,10]).setColor(1,0.5,0.3);**