I am writing a C# program that has a cube object that allows the user to move it in the x y and z axis. However i want them to be able to rotate it aswell.
My matrix is defined as so: public double[, ] matrix = new double[4, 4];
So for example i was able to scale the cube via this code.
public void initAsScalingMatrix(double sx, double sy, double sz) {
initAsIdentityMatrix();
matrix[0, 0] = sx; // scale x
matrix[1, 1] = sy; // scale y
matrix[2, 2] = sz; // scale z
matrix[3, 3] = 1;
}
So my question is. How could i use the same approach to rotate the cube around for example the x axis?
EDIT---
Hi,
I have figured out how to rotate it but it is doing it from way of in the top left corner.
matrix[0, 0] = Math.Cos(rz);
matrix[0, 1] = Math.Sin(rz);
matrix[1, 0] = -(Math.Sin(rz));
matrix[1, 1] = Math.Cos(rz);
How could it rotate from the center?