This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Perpective division

Tags: None
(comma "," separated)
wrabbit
Registered Member
Posts
2
Karma
0

Perpective division

Wed Sep 08, 2010 5:14 am
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.
Hauke
Registered Member
Posts
109
Karma
3
OS

Re: Perpective division

Wed Sep 08, 2010 7:47 am
wrabbit wrote:Vector3f pClip = perspective * pView;
pClip /= pClip[3]; // run-time error. Seems there isn't a 'w'


It seems as if you are running into an indexing error over here. pClip[3] is undefined - you need pClip[2].

- Hauke
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Perpective division

Wed Sep 08, 2010 8:19 am
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;
wrabbit
Registered Member
Posts
2
Karma
0

Re: Perpective division

Wed Sep 08, 2010 4:46 pm
Thanks!


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]