![]() Registered Member ![]()
|
hi all..
I'm using Eigen to do a perspective transform and this is a Real noobish question, but how do you do you cleanly handle the "w" coordinate? Currently i have something along the lines of: Transform<float, 3> perspective; // initialized elsewhere.. Vector3f pView(1,2,3); // there should be a 'w' set to 1 for this.. Vector3f pClip = perspective * pView; pClip /= pClip[3]; // run-time error. Seems there isn't a 'w' The Geometry tutorial page has a brief mention of the difference between points and vectors, but i probably missed a section somewhere dealing with homogeneous coordinates. |
![]() Registered Member ![]()
|
It seems as if you are running into an indexing error over here. pClip[3] is undefined - you need pClip[2]. - Hauke |
![]() Moderator ![]()
|
if you are using Eigen 2, then the perspective division is done for you when you provide a 3D vector. You can also use a homogeneous vector:
Vector4f a(A,2,3, 1), b; b = perspective * a; and do the division yourself: b /= b.w(); if you are using Eigen 3 beta1, then you also need to specify you want a projective transform: Transform<float,3,Projective> perspective; |
![]() Registered Member ![]()
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]