[vtkusers] how to compute the distance between two 3D

Nehme Bilal nbilal at mirarco.org
Sat Jan 31 13:03:28 EST 2009


Hi,

> 2). How could I measure or compute the distance between 
>any 3D points

double point1[3] = {x1, y1, z1};
double point2[3] = {x2, y2, z2};

distance = 
sqrt(vtkMath::Distance2BetweenPoints(point1,point2));


> Date: Fri, 30 Jan 2009 20:25:39 +0200
>From: "Sercani" <sercanimailgroups at gmail.com>
> Subject: Re: [vtkusers] how to compute the distance 
>between two 3D
> 	points.
> To: "'Dongqing Chen'" 
><dqchen at cvip.louisville.edu>,	<vtkusers at vtk.org>
> Message-ID: <012701c98308$2bf93860$83eba920$@com>
> Content-Type: text/plain; charset="iso-8859-9"
> 
> Hi Chen;
> 
> Check out this tutorial : 
>http://devsample.org/index.php?option=com_content
> <http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27
>> &task=view&id=48&Itemid=27 it is for getting the scalar 
>>value of a clicked
> point in 2d projection but you must do the similar thing 
>for getting the id
> of a clicked point in 3d scene.After getting the point 
>id you can calculate
> the structured position of this point using dimensions 
>of imagedata. For
> computing the distance of points check out the vtkMath 
>class
> http://www.vtk.org/doc/nightly/html/classvtkMath.html#2ae99578ae65acefe517b1
> 2a7f4068e1 or simply write 
> 
> dx = Ax-Bx 
> 
> dy = Ay-By 
> 
> dz = Az-Bz 
> 
> distance = sqrt(dx*dx + dy*dy + dz*dz)
> 
> 
> 
> Yours sincerely.
> 
> Sercani.
> 
> 
> 
>From: vtkusers-bounces at vtk.org 
>[mailto:vtkusers-bounces at vtk.org] On Behalf
> Of Dongqing Chen
> Sent: Friday, January 30, 2009 8:37 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] how to compute the distance between 
>two 3D points.
> 
> 
> 
> Dear All:
> 
> 
> 
>   I have two small questions, and want to ask for any 
>suggestion from this
> mail list. 
> 
> 
> 
>  I could display the 3D model (surface rendering), and I 
>may figure out its
> 2D axial/sagittal/coronal projections, then 
> 
> 
> 
> 1). how could I find the corresponding 2D points on 
>these three projects for
> a given 3D point, say, if I have a 3D point on the 3D 
>model, which VTK class
> I should use to find its projection pionts on 2D axial, 
>sagittal and
> coronal?
> 
> 
> 
> 2). How could I measure or compute the distance between 
>any 3D points, say,
> which VTK class allows me to know its 3D position if I 
>click on a 3D point?
> 
>   
> 
> Best Wishes,
> 



More information about the vtkusers mailing list