Note that there are some explanatory texts on larger screens.

plurals
  1. PO3x3 Matrix Rotation in C++
    primarykey
    data
    text
    <p>Alright, first off, I know similar questions are all over the web, I have looked at more than I'd care to count, I've been trying to figure it out for almost 3 weeks now (not constantly, just on and off, hoping for a spark of insight).</p> <p>In the end, what I want to get, is a function where you pass in how much you want to rotate by (currently I'm working in Radian's, but I can go Degrees or Radians) and it returns the rotation matrix, preserving any translations I had.</p> <p>I understand the formula to rotate on the "Z" axis in a 2D cartesian plane, is:</p> <pre><code>[cos(radians) -sin(radians) 0] [sin(radians) cos(radians) 0] [0 0 1] </code></pre> <p>I do understand Matrix Maths (Addition, Subtraction, Multiplication and Determinant/Inverse) fairly well, but what I'm not understanding, is how to, step-by-step, make a matrix I can use for rotation, preserving any translation (and whatever else, like scale) that it has.</p> <p>From what I've gathered from other examples, is to multiply my current Matrix (whatever that may be, let's just use an Identity Matrix for now), by a Matrix like this:</p> <pre><code>[cos(radians) - sin(radians)] [sin(radians) + cos(radians)] [1] </code></pre> <p>But then my original Matrix would end up as a 3x1 Matrix instead of a 3x3, wouldn't it? I'm not sure what I'm missing, but something just doesn't seem right to me. I'm not necessarily looking for code for someone to write for me, just to understand how to do this properly and then I can write it myself. (not to say I won't look at other's code :) )</p> <p>(Not sure if it matters to anybody, but just in-case, using Windows 7 64-bit, Visual Studio 2010 Ultimate, and I believe OpenGL, this is for Uni)</p> <p>While we're at it, can someone double check this for me? Just to make sure it seems right.</p> <p>A translation Matrix (again, let's use Identity) is something like this:</p> <pre><code>[1, 0, X translation element] [0, 1, Y translation element] [0, 0, 1] </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload