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:quick_reference_transforms [2020/11/28 06:24]
JSCAD Editor
en:quick_reference_transforms [2021/04/30 08:23] (current)
JSCAD Editor
Line 8: Line 8:
  
 ^  Transform  ^  Notes  ^ ^  Transform  ^  Notes  ^
-| const newshape = align({}, oldshape) tbw  | +| 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({}, oldshape, [])  | **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 = centerX(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerX | API]]  | 
 +| const newshape = centerY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerY | API]]  | 
 +| const newshape = centerZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.centerZ | API]]  | 
 +| const newshape = mirror({origin: [55, 5], normal: [0, 0, 10]}, 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]]  | 
 +| const newshape = mirrorY(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorY | API]]  | 
 +| const newshape = mirrorZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.mirrorZ | API]]  | 
 +| const newshape = rotate([Math.PI / 4, 0, 0], 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]]  | 
 +| const newshape = rotateZ(oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.rotateZ | API]]  | 
 +| const newshape = scale([5, 0, 10], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scale | API]]  | 
 +| const newshape = scaleX(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleX | API]]  | 
 +| const newshape = scaleY(0.5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleY | API]]  | 
 +| const newshape = scaleZ(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.scaleZ | API]]  | 
 +| const newshape = transform(mat4.rotateX(Math.PI/4), oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.transform | API]]  | 
 +| const newshape = translate([5, 0, 10], oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translate | API]]  | 
 +| const newshape = translateX(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateX | API]]  | 
 +| const newshape = translateY(0.5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateY | API]]  | 
 +| const newshape = translateZ(5, oldshape)  | [[https://www.openjscad.xyz/docs/module-modeling_transforms.html#.translateZ | API]]  |
  
-^  2D Transformations  ^  3D Transformations  ^ 
-| 2Dshape = 2Dshape.translate([-2, -2]); | 3Dshape = 3Dshape.translate([1,2,3]); | 
-| 2Dshape = 2Dshape.rotateZ(20); | 3Dshape = 3Dshape.rotateX(90); | 
-| ::: | 3Dshape = 3Dshape.rotateY(-180);  | 
-| ::: | 3Dshape = 3Dshape.rotateZ(45);  | 
-| 2Dshape = 2Dshape.rotate(center, axis, degrees);  | 3Dshape = 3Dshape.rotate(center, axis, degrees);  | 
-| 2Dshape = 2Dshape.rotateEulerAngles(alpha, beta, gamma, position);  | 3Dshape = 3Dshape.rotateEulerAngles(alpha, beta, gamma, position);  | 
-| 2Dshape = 2Dshape.scale([0.7, 0.9]);  | 3Dshape = 3Dshape.scale([1,2,3]);  | 
-| 2Dshape = 2Dshape.center([true,true]); **/* center X & Y axis */**  | 3Dshape = 3Dshape.center([true,true,true]); **/* center X & Y & Z axis */**  | 
-| 2Dshape = 2Dshape.mirroredX();  | 3Dshape = 3Dshape.mirroredX();  | 
-| 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.2, 8); **/* radius, resolution */**  | 3Dshape = 3Dshape.expand(0.2, 8); **/* radius, resolution */**  | 
-| 2Dshape = 2Dshape.contract(0.2, 8); **/* radius, resolution */**  | 3Dshape = 3Dshape.contract(0.2, 8); **/* radius, resolution */**  | 
- 
-//Note: Shape transformations can be chained together. Example:// 
- 
-**var 3Dshape = CSG.cube().rotate(45).translate([20,0,10]).setColor(1,0.5,0.3);**