OpenGL API Specifications
Documents and Learning ResourcesSupport Libraries and FrameworksFunction Libraries and GeneratorsThis list contains some basic resources for getting started with, and developing for, OpenGL 3.0 and onwards. Contact your forum moderator if you want to contribute to the list or have any comments.Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 15 December 2012 - 09:40 PM
Posted 16 December 2012 - 03:03 AM
Posted 16 December 2012 - 04:14 AM
The entire bottom row is used for the perspective division, not just the B-element.I'm not really sure if A is used at all, I did this a long time ago, but B is supposed to be the perspective divide element.
Or at least B and the projection matrix modify the 4th element of the position, so that in clip space if you divide by it, you get the ndc coordinates.
It doesn't make much sense to talk about how to apply these elements to a 3-element vector. You simply cannot multiply a 3-element vector by a 4-by-4 matrix in the first place. What you do when adding multiplying the 3-element vector by the rotation part and then adding the translation part as a separate step is really just assuming that the missing fourth component of the 3-element vector is unity. In order to handle the fourth row of the matrix correctly, you have to do the same assumption again, carry out the multiplication, and see how the bottom row affects the other three elements, as well as performing the final perspective division to ensure that the assumption that the fourth component really is unity even after the multiplication.how would I apply A and B to a Vec3? ( I know how to translate and rotate )
Edited by Brother Bob, 16 December 2012 - 04:14 AM.
Posted 16 December 2012 - 05:09 PM
Posted 16 December 2012 - 05:26 PM
Posted 16 December 2012 - 05:42 PM
>> M M = 0.7500 0 0 0 0 1.0000 0 0 0 0 -1.0001 -0.2000 0 0 -1.0000 0 >> v v = 1 2 3 1 >> p = M*v p = 0.7500 2.0000 -3.2003 -3.0000See how the fourth element of the vector p is -3.0? That's because your 3-dimensional vector is actually a 4-dimensional vector with an implicit element at the end with a value of 1.0.
>> p./p(4) ans = -0.2500 -0.6667 1.0668 1.0000So your resulting projected 3-dimensional vector is (-0.2500, -0.6667, 1.0668).
Edited by Brother Bob, 16 December 2012 - 05:46 PM.
Posted 17 December 2012 - 05:15 AM
octave:3> scale(1,2) ans = 1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 1 octave:4> v=[1;2;3;1] v = 1 2 3 1 octave:6> scale(1,2)*v ans = 1 4 3 1 octave:7> rot(pi/2) ans = 1.00000 0.00000 0.00000 0.00000 0.00000 0.00000 -1.00000 0.00000 -0.00000 1.00000 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 octave:8> rot(pi/2)*v ans = 1 -3 2 1 octave:9> inverse(rot(pi/2)) ans = 1.00000 0.00000 -0.00000 -0.00000 0.00000 0.00000 1.00000 -0.00000 0.00000 -1.00000 0.00000 -0.00000 0.00000 0.00000 0.00000 1.00000 octave:11> T=transl(1); octave:19> S=scale(2); octave:20> S*T*v ans = 4 2 3 1 octave:21> T*S*v ans = 3 2 3 1
Posted 17 December 2012 - 03:08 PM
Posted 17 December 2012 - 04:01 PM
You cannot invert the individual sections of a matrix just like that. It just happens to work for translation under very specific circumstances. Likewise, you can invert other sections under other specific conditions.thank you, larspensjo. I was delighted to find octave available for my linux distro. but how about projection/perspective matrices?
I presume the way to invert the perspective section of a matrix is to just negate the values, just the same as negating the translation parts. is this correct?
Posted 18 December 2012 - 09:51 AM
But take a look at how OpenGL's matrices are commonly designed here in appendix F. It lists their inverse also.
Edited by caibbor, 18 December 2012 - 12:19 PM.
Posted 18 December 2012 - 01:08 PM
Posted 18 December 2012 - 06:07 PM
Edited by caibbor, 18 December 2012 - 06:09 PM.
Posted 18 December 2012 - 06:19 PM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.