Shape Manipulation

Methods are divided into following categories.


    There is more than one way to rotate a shape. Follow the examples


    Scaling a shape


    Using Transformation object to translate a shape


//This example shows using createTransformation method to 
//move, rotate and scale an object in one shot.

function build() {

    //create cylinder lying on the X-Z plane. 

    //You can verify it by returning solid before transformation
	let s1 = cadlib.cylinder({radius:5, height:1});

    //Move the shape on +Y axis by 30. 
    //Rotate around X axis by 30 degreess
    //Scaling factor is set to 2. 

	let xform = {
        position: new Vec3(0, 30, 0),
        quaternion: { x:1, y:0, z:0, w: cadlib.toRadians(30)},
        scale: {factor:2}
    //create transformation object
    let t = cadlib.createTransformation(xform);
    //apply transform by creating a clone.
    let s2 = s1.transform(t, true);
    //return combined solid.
    return cadlib.fuse([s1, s2]);

    //You should see original solid and transformed solid