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/11/28 06:38]
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: ['none', 'center', 'none']}, 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 newshapes = align({modes: ['min', 'center', 'none'], alignTo: [10, null, 10], grouped: true }, oldshape, [oldshape0, oldshape1])  | **Note: returns an array of new shapes** +| 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 = 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 = centerX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerX | API]]  | 
-| const newshape = centerX(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerX | API documentation]]  | +| const newshape = centerY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerY | API]]  | 
-| const newshape = centerY(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerY | API documentation]]  | +| const newshape = centerZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerZ | API]]  | 
-| const newshape = centerZ(oldshape) See [[https://www.jscad.xyz/docs/module-modeling_transforms.html#.centerZ | API documentation]]  | +const newshape mirror({origin: [55, 5], normal: [0010]}, oldshape))  [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirror | API]]  
- +const newshape mirrorX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorX | API]]  | 
-^  2D Transformations  ^  3D Transformations  ^ +const newshape mirrorY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorY | API]]  | 
-2Dshape 2Dshape.translate([-2-2]); | 3Dshape = 3Dshape.translate([1,2,3]); | +const newshape mirrorZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorZ | API]]  | 
-| 2Dshape = 2Dshape.rotateZ(20)3Dshape = 3Dshape.rotateX(90); +const newshape rotate([Math.PI / 4, 0, 0], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotate | API]]  | 
-::: | 3Dshape 3Dshape.rotateY(-180) | +const newshape rotateX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateX | API]]  | 
-::: | 3Dshape = 3Dshape.rotateZ(45);  | +const newshape rotateY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateY | API]]  | 
-2Dshape 2Dshape.rotate(center, axis, degrees) 3Dshape = 3Dshape.rotate(center, axis, degrees);  | +const newshape rotateZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateZ | API]]  | 
-2Dshape 2Dshape.rotateEulerAngles(alpha, beta, gamma, position) 3Dshape = 3Dshape.rotateEulerAngles(alpha, beta, gamma, position);  | +const newshape scale([5, 0, 10], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scale | API]]  | 
-2Dshape 2Dshape.scale([0.7, 0.9]) 3Dshape = 3Dshape.scale([1,2,3]);  | +const newshape scaleX(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleX | API]]  | 
-2Dshape 2Dshape.center([true,true]); **/* center X & Y axis */**  3Dshape = 3Dshape.center([true,true,true]); **/* center X & Y & Z axis */**  | +| const newshape scaleY(0.5oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleY | API]]  | 
-2Dshape 2Dshape.mirroredX() 3Dshape = 3Dshape.mirroredX();  | +const newshape scaleZ(5oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleZ API]]  | 
-2Dshape 2Dshape.mirroredY() 3Dshape = 3Dshape.mirroredY();  | +| const newshape transform(mat4.rotateX(Math.PI/4)oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.transform | API]]  | 
-::: | 3Dshape 3Dshape.mirroredZ() | +const newshape translate([5010], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translate | API]]  | 
-| 2Dshape = 2Dshape.mirrored(plane); | 3Dshape = 3Dshape.mirrored(plane);  | +| const newshape translateX(5oldshape | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateX | API]]  | 
-2Dshape 2Dshape.transform(matrix) 3Dshape = 3Dshape.transform(matrix); +const newshape translateY(0.5oldshape | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateY | API]]  | 
-| **/* not supported yet */**  3Dshape 3Dshape.setColor(r,g,b) **/* a = 1.0 */**  | +| const newshape translateZ(5oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateZ | API]]  |
-::: | 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.2, 8); **/* radius, resolution */**  3Dshape 3Dshape.expand(0.28); **/* 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);**