0

I would like to ask what the steps are to setting a 4x4 Rotation Matrix using degrees for all separate X, Y, Z axis.

Illustrations would be much appreciated, thanks!

(C++ implementation preferred)

Mr_Pouet
  • 4,061
  • 8
  • 36
  • 47
Evalkyre
  • 9
  • 2
  • 2
    Did you consider using google? https://en.wikipedia.org/wiki/Rotation_matrix – Mr_Pouet Dec 17 '15 at 22:16
  • 2
    Do you have an implementation in some programming language in mind? – Mr_Pouet Dec 17 '15 at 22:16
  • 1
    I tried Wikipedia, perhaps I did not thoroughly go through it, but there was not a clear illustration for setting up a 4x4 rotational matrix. Preferably in C++. – Evalkyre Dec 17 '15 at 22:29
  • Possible duplicate of [How do I compose a rotation matrix with human readable angles from scratch](http://stackoverflow.com/questions/28075743/how-do-i-compose-a-rotation-matrix-with-human-readable-angles-from-scratch) – Spektre Dec 18 '15 at 09:21

1 Answers1

0

Assuming a C++ program, if you want a header-only library that will do this for you, you can use the amazing glm:

http://glm.g-truc.net/0.9.6/index.html

And use glm::rotate as such:

glm::mat4 Projection = glm::perspective(glm::radians(45.0f), 4.0f / 3.0f, 0.1f, 100.f);
glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
glm::mat4 MVP = Projection * View * Model;

You can find the implementation on Github if you are interested in writing your own: matrix_transform.inl

Mr_Pouet
  • 4,061
  • 8
  • 36
  • 47