rotating an object


I am using the gridded3dset to generate a number of shapes. I would like to rotate the objects by updating the points in the sample data (sample[][]) with new coordinates.

Does anyone have a piece of code to perform rotation of an object by transforming the coordinates of the data points given some angles (say with respect to x and with respect to z for example)? I would be very thankful if someone is willing to share the code with me.