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