User Tools


Shape Transformations

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);