Re: [Algorithms] Up Vector in Projection Matrix
Brought to you by:
vexxed72
From: Ron L. <ro...@do...> - 2000-08-09 23:25:26
|
----- Original Message ----- From: "Kelmenson, Dan" <Dan...@br...> To: <gda...@li...> Sent: Wednesday, August 09, 2000 2:34 PM Subject: RE: [Algorithms] Up Vector in Projection Matrix > > -----Original Message----- > > From: Pai-Hung Chen [mailto:pa...@ac...] > > > > > > > > When you specify a point or direction to "look at", you have only > > specified > > > two of the degrees of freedom of the system. That object > > could be in the > > > middle of the screen - either upside-down - or right way up > > - or at any > > > 'roll' angle in between. > > > > > > The 'up' vector only has to be enough to resolve that issue > > - and only one > > > of its degrees of freedom is needed. Hence, there are a > > wide variety of > > > vectors that will do the job. The only constraint is that > > the up vector > > > and the 'look direction' are not parallel. > > > > > > Hence, so long as your character can't look absolutely > > vertically upwards > > > or absolutely vertically downwards, an 'up' vector of > > (0,1,0) will do > > fine. > > > > That explains everything (though I don't know why/how the > > underlying math > > works). An ever-confusing question got explained! Thanks a lot! :-) > > > > The most likely reason the math worked (the reason the math worked in my > program, and most likely in yours...) is that the main use of the 'up' > vector is crossing it with the forward/view direction. As long as your > character/camera doesn't lean to the side, the true (0,1,0) up vector and > the actual perpendicular-to-forward up vector will both be coplanar with the > forward vector, and therefore give you the same cross product. > Another way to think about it is that the "look-at" functions in the various APIs and toolkits do not require that the up vector argument be perpendicular to the look-at vector argument, but only that they be linearly independent. Then it's a fact that there is a unique unit up vector that IS perpendicular to the look-at vector argument, in the plane determined by the two vector arguments (why they must be linearly independent) and pointing, in that plane, to the same side of the argument look-at vector as points the argument up vector. The API look-at routine computes that perpendicular up vector from the argument vectors, either by iterated cross products or, more likely, by the Gram-Schmidt formula, to use in constructing the correct view matrix. |