Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Jan 2013
Offline Last Active Feb 02 2013 09:09 AM

Posts I've Made

In Topic: Help needed setting up camera transform

08 January 2013 - 05:22 AM



Thanks so much for this great reply.  It has helped me greatly.  I read the section about column major vs row major, and that explains a lot.  I have been using this math textbook, and it has always presented the math in column major format, and didn't discuss row major at all.  I had seen the concept mentioned before, but when I looked it up on Wikipedia, it seemed to be discussing the *computing* aspect of row vs column major, i.e. how the matrix is laid out in memory.  So a big thanks for this.




It also explains why I was getting confused when looking at different web site tutorial pages.  Some would be in column major, and some in row major, and had not explicitly mentioned which format they were using.



Hi Kevin,

I hope I am not too late to help you with your problem/question. You did right to watch on scratchapixel but you should look at this page in particular:


Basically knowing whether you use a right or left hand coordinate system is indeed important but in fact, in that particular case, it has little to do with whether you matrix is correct or not. What is important for constructing your matrix from the 3 vectors (up, right, forward) is whether you renderer uses row- or column-major notation for matrices.



As mentioned in the page above if you use the row-major notation, your 3 vectors should be written vertically in the matrix and if you use column-major they should be written horizontally.



//kt Are you sure about the above statements?  After reading the ScratchAPixel site, I think that in column major, the columns represent the basis (axes).  The page has a helpful table at the end that summarizes the difference, and states this explicitly

In other words, assuming you have the vectors A B C (representing the right, top and forward vector from your camera coordinate system) you should write:

Ax Bx Cx
Ay By Cy
Az Bz Cz

If you use row-major notation.


Yes.  I agree with this.


Now I will explain you why (there's a way an easy of checking how you should write the matrix if you can't remember it by heart). Remember that if you use row-major vector then the vector-matrix multiplication needs to be written as:




The example was helpful.

Hope it helps a bit. This should be maybe clearer on scratchapixel indeed. I would be you I would contact them and asked them questions when you don't know or can't find information on their website. I work with them and know they are keen on improving their website, etc.

Hope I didn't make things more messy in your mind though ;-)


This has been very helpful.  I have written my own vector and matrix classes, and I am using column major format.  I am going to go back through my matrix setup and make sure I am being consistent.


I am heading our for a skiing trip,  :-) , in a few days, so I may not get to work on this for few weeks.  But I'll try to post back on my progress later.


One other quick question before I go, regarding the right hand rule.


When I put my right hand into the right-hand position (a quick google search of right hand rule images demonstrates what I am talking about), I have my thumb pointing upward, my index finger pointing "in" and my middle finger is pointing to the left.  In another graphics engine I used to work with, Genesis3d (http://www.genesis3d.com/~kdtop/ ) there were functions for GetIn, GetLeft, GetUp.  So it seemed that up-in-left were the names used to describe the orientation of a matrix.  But this is different from most tutorials that I am now reading that describe up-in-right.


If I consider my thumb to be the x axis, my index finger the y axis, and my middle finger to be the z axis, and then rotate my hand such that it corresponds with the typical display of the x, y, and z axes, then it seems that there would be this mapping:

Thumb -- x-axis -- "right"

index finger -- y axis -- "up"

middle finger -- z axis -- "out"


Is this different, or just an orientation variance?  In your post, and in many others, you mention "up, forward, right", but this seems different from up-in-left.


Thanks again so much for your help (and for anyone else that cares to comment).


Kevin (kdtop)

In Topic: Help needed setting up camera transform

06 January 2013 - 07:30 AM

Normally the camera is set using a perspective matrix and a view matrix.


A can't really explain the details but if you want, you can check the glm library.

I know it is for C++, but you can open the header files (it is a library containing only header files), and see in particular how the glm::perspective() and glm::lookat() work, you can then multiply the two matrices and get the view matrix which is the camera matrix.

They're located in the gtc/matrix_transform.hpp file.


Hope it helps.


Thanks for the feedback.  I'll see if I can find code examples.   


I am trying to separate the view matrix and perspective matrix to ensure I understand each separately.