## Chapter 5 Adjusting to the Screen's Aspect Ratio |

18 Oct 2013, 11:26
Syed Farazul Islam (2 posts) |
Hi, I believe I understood most of this chapter and the linear algebra side of things. I was able to do the suggested exercise, panning and zooming. But I don’t feel like I have a full understanding of why certain things are happening with the projection matrix. It’s bugging me and I don’t feel like carrying on until I fully understand it! Please help me out! First of all, in the projection matrix there are lots of little fractions. What is the significance of 2 as the numerator? Is this because normalized coordinates are in the range of -1 and 1? In OrthoM() when I add the 1 (or any other number) to bottom, top and/or left, right it allows me to pan up and then to the right. Is this because the clipping plane has been changed? In OrthoM() when I make left more left, right more right, bottom more lower and top more higher - it zooms out. I don’t understand why changing the near and far has no effect on zooming. Lastly (I think) I don’t understand why the aspect ratio is calculated and used for left, right ONLY then top, bottom ONLY. |

28 Oct 2013, 17:38
Kevin Brothaler (27 posts) |
Hi Syed, The projection matrices can be quite tricky, I agree! :) 1) What is the significance of 2 as the numerator? Is this because normalized coordinates are in the range of -1 and 1? Yes, the normalized coordinates are in the range of -1 to 1. 2) In OrthoM() when I add the 1 (or any other number) to bottom, top and/or left, right it allows me to pan up and then to the right. Is this because the clipping plane has been changed? Adding numbers to bottom, top, left, right changes the range of coordinates that get mapped onto the screen. So for example, instead of mapping 0 to 100 onto the screen, you might be mapping 100 to 200 onto the screen. This would pan things to the right. 3) In OrthoM() when I make left more left, right more right, bottom more lower and top more higher - it zooms out. I don’t understand why changing the near and far has no effect on zooming. By increasing the range, you map a wider range onto the screen: 0 to 500 instead of 0 to 100 would cause things to appear 5x smaller. Changing near & far has no effect on zooming as the orthographic projection makes things appear the same size no matter how far or near they are. So for example, if you have a mapping of 0 to 100, something that is 50 units wide will appear the same size no matter if it is close to you or very far away from you. You have the right understanding: changing the range will zoom in and out, and it will zoom everything equally. For your last question: what the code in the book is doing is if the screen is in landscape mode (width greater than height), then it expands the view horizontally. If it is in portrait mode, then it fixes the width to -1 to 1 and expands the view vertically. This is just one way of doing things and you could choose to always expand/shrink the view horizontally. Cheers, Kevin |

07 Nov 2013, 21:49
Syed Farazul Islam (2 posts) |
Thanks Kevin. I only saw your reply a few days ago. Whilst I was waiting I re-read the book. Everything is sinking in and I am back on chapter 5. Just to clarify with your answer to question 1 above. It is 2 because 1–1 = 2? |

11 Nov 2013, 19:09
Kevin Brothaler (27 posts) |
Hi Syed, In Appendix 1 there is an example that walks through an “identity” orthographic projection. In this example, if we pass in a left of -1 and a right of +1 (the same as the left & right of normalized device coordinates), then the term of the upper-left portion of the matrix is evaluated as (2 / (1 - -1)), which becomes (2 / (1 + 1)), or 2 / 2, or 1. Having a term of 1 means that the orthographic projection doesn’t change the X part of the coordinate, which is what we’d expect if we set up the left - right range to be the same as normalized device coordinates. This is a lot easier to follow in the appendix since you can see visual examples of the matrix there; please let me know if that helps out. :) |

You must be logged in to comment |