[vtkusers] vtkPoints ...how to work with them.
David Gobbi
david.gobbi at gmail.com
Wed Feb 17 08:20:47 EST 2010
You can't set the bottom row to zero, because when (x, y, z, w) is
multiplied by that matrix, it will give w = 0. So when
vtkPerspectiveTransform does the divide-by-w, you get a
divide-by-zero.
Try using the following 4x4 matrix instead, and then
vtkPerspectiveTransform will do the perspective division for you so
that you don't have to do it yourself:
a b c d
e f g h
0 0 0 0
j i j k
The above matrix will set z=0 and set w=x*j + y*i + z*j + k. Then
vtkPerspectiveTransform will divide the new (x,y,z) by this "w" value
before it returns. I'm guessing that this is what you want.
David
On Wed, Feb 17, 2010 at 3:04 AM, Giancarlo Amati
<ilferraresebono at hotmail.it> wrote:
> Hi David,
>
> well my transformation matrix is aprojection matrix (3x4) but I add a 4th
> row which is null. So basically my matrix is:
>
> a b c d
> e f g h
> j i j k
> 0 0 0 0
>
> As I need to transform 3D points into my 2D image space.
> now, as I need to dived X,Y by Z which becomes a scaling factor.
>
> So what I want to visualise is X/Z, Y/Z, 1 in (uv coordinate system).
>
>> From: david.gobbi at gmail.com
>> Date: Tue, 16 Feb 2010 13:00:08 -0700
>> Subject: Re: [vtkusers] vtkPoints ...how to work with them.
>> To: ilferraresebono at hotmail.it
>> CC: vtkusers at vtk.org
>>
>> Show us your transform matrix. I'd bet that when your points are
>> multiplied by the matrix, the homogeneous coordinate ends up being
>> zero.
>>
>> David
>>
>>
>> On Tue, Feb 16, 2010 at 12:09 PM, Giancarlo Amati
>> <ilferraresebono at hotmail.it> wrote:
>> > Hello everybody, this is my code:
>> >
>> > vtkSmartPointer<vtkTransformPolyDataFilter> pdF =
>> > vtkTransformPolyDataFilter::New();
>> > pdF->SetInputConnection(pdNorm->GetOutputPort());
>> > pdF->SetTransform(perspT);
>> > pdF->Update();
>> >
>> >
>> > vtkSmartPointer<vtkPolyData> T_persp_pd = pdF->GetOutput();
>> > T_persp_pd->Update();
>> >
>> > vtkSmartPointer<vtkPoints> T_pdPoints = T_persp_pd->GetPoints();
>> > cout << "N points: " << T_persp_pd->GetNumberOfPoints();
>> >
>> >
>> > //Normalize the points
>> > for( int i = 0; i<T_persp_pd->GetNumberOfPoints(); i++) {
>> > double p[3];
>> > T_persp_pd->GetPoints()->GetPoint(i,p);
>> > cout<< "POints i: " << i << " " << p[0] << endl;
>> > p[0] = p[0]/p[2];
>> > p[1] = p[1]/p[2];
>> > p[2] = p[2]/p[2];
>> > }
>> >
>> > when I print out the 3D vector p, I always get: -1.INF0000000000 which
>> > is
>> > clearly a mistake. What's the problem in my code?
>> >
>> > thanks a lot!
>> > Giancarlo
>> >
>> > ________________________________
>> > Troppe caselle di posta? Gestiscile da Hotmail!
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the VTK FAQ at:
>> > http://www.vtk.org/Wiki/VTK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.vtk.org/mailman/listinfo/vtkusers
>> >
>> >
>
> ________________________________
> Ci sai fare con le parole? Scoprilo su Typectionary!
More information about the vtkusers
mailing list