Correct order of transformations

Hi guys!

I would like to ask for some help regarding OpenGL transformations. Before someone would ask, yes, it is a university assignment, but I’m not asking for any code, merely the theoretical answer.

One of the tasks is to rotate an existing cube (which is originally at the origo) around an arbitrary axis. This axis is a line, which the user can enter two sets of coordinates for to define it, as well as an angle of rotation. I handled the drawing of the line, the user input already and I know how to use the transformation functions, but I am stuck with this line rotation in theory.

Any help would be highly appreciated!

[QUOTE=slashmaster;1285618]Hi guys!

I would like to ask for some help regarding OpenGL transformations. Before someone would ask, yes, it is a university assignment, but I’m not asking for any code, merely the theoretical answer.

One of the tasks is to rotate an existing cube (which is originally at the origo) around an arbitrary axis. This axis is a line, which the user can enter two sets of coordinates for to define it, as well as an angle of rotation. I handled the drawing of the line, the user input already and I know how to use the transformation functions, but I am stuck with this line rotation in theory.

Any help would be highly appreciated![/QUOTE]

Well the transfromation are done like this : Rotate the thing scale it than move it . when you want this to be a code in opengl you just have to multiplay the 3 matrices in the inverse ordare which mean
final transformation = translate_ matrix * scaling_matrix * Rotate_matrix
some code from my transform class


void Transforms::translate(const glm::vec3& val)
{
	this->_T = glm::translate(val);
}

void Transforms::rotate(const glm::vec3& val)
{
	glm::mat4 rotXmatrix  = glm::rotate(val.x,glm::vec3(1.0,0.0,0.0));
	glm::mat4 rotYmatrix  = glm::rotate(val.y,glm::vec3(0.0,1.0,0.0));
	glm::mat4 rotZmatrix  = glm::rotate(val.z,glm::vec3(0.0,0.0,1.0));

	this->_R = rotZmatrix * rotYmatrix * rotXmatrix;
}

void Transforms::scale(const glm::vec3& val)
{
	this->_S = glm::scale(val);
}

void Transforms::update()
{
	this->_m = this->_T * this->_S * this->_R; // this is the model matrix
}