Rotation

Rotate a Shape around center or around a specified edge
function build() {
    //Create a cube and rotate it around an edge at the base
    
    //Define a boolean type parameter named rotateAroundCenter
    let rotateAroundCenter = params.rotateAroundCenter;

    //Create shape
    let shape1 =  cadlib.box({width:2, height:8, depth: 4});
    
    
    //Find the edge Id by clicking on the edge in the scene.
    let edge = shape1.findEdgeByID(11);;
    
    //Open the build log to notice the points. You should an array of 2 vertices, total 6 entries
    let points = edge.polygonize();    
    //console.log(points);

    //grab first vertex
    let p1 = new Vec3(points[0], points[1], points[2]); 

    //grab second vertex
    let p2 = new Vec3(points[3], points[4], points[5]);  

    //define axis for rotation
    let axis = p1.sub(p2).normalize();
    //console.log(axis) ;
    
    
    
    //Depending on how axis is costructed (p1.sub(p2) or p2.sub(p1)), the angle may be +ve or -ve for clockwise or anticlockwise

    //Make choice of rotation parametric :  around center or another point
    if(rotateAroundCenter) {
        shape1.rotate(new Vec3(0,0,0), axis, 45);
    } else {
        //Note p1 is one vertex of bottom edge
        shape1.rotate(p1, axis, 45);
    }

    return shape1;
}
Using createTransformation object for rotation

//Required function

function build() {

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

    let s1 = cadlib.cylinder({radius:5, height:2});
    
    //You can verify it by returning solid before transformation
    //return s1;
	
	//use quaternion to achieve rotation along X axis
	let xform = {
		quaternion: {x:1, y:0, z:0, w: cadlib.toRadians(10) },
		
	};

	//create transformation object
	let t = cadlib.createTransformation(xform);

	//apply transform
	s1.transform(t, false);

}

Using transformation object for rotation around multiple axis

//Required function

function build() {

	//create cylinder lying on the X-Z plane. 
    
    let s1 = cadlib.cylinder({radius:5, height:2});
    
    //You can verify it by returning solid before applying transformation
	//return s1;

    //Set quaterinion to rotate the cylinder around multiple axis
    
    //rotation around X and Z axis by 30 degrees
	
	let xform = {
		quaternion: {x:1, y:0, z:1, w: cadlib.toRadians(30)}
	};

    //create the transformation object
    let t = cadlib.createTransformation(xform);
    
    //Apply transform
    s1.transform(t);

    return s1;

}