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