]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implemenation of new function Point<dim>::distance (const Point<dim> &p)
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 6 Sep 2000 11:09:23 +0000 (11:09 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 6 Sep 2000 11:09:23 +0000 (11:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@3299 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/point.h

index c094c31ca8122dd091abca2b7d58eb3af1361228..09caecfb2d455f9f856814ffd6d35d96cbe53782 100644 (file)
@@ -135,6 +135,12 @@ class Point : public Tensor<1,dim>
                                      *  the square of the norm.
                                      */
     double              square () const;
+    
+                                    /**
+                                     * Returns the distance of @p{this} 
+                                     * point to the point @p{p}.
+                                     */
+    double distance (const Point<dim> &p) const;
 
 
                                     /**
@@ -308,8 +314,6 @@ double Point<dim>::operator * (const Point<dim> &p) const
 };
 
 
-
-
 template <int dim>
 inline
 double Point<dim>::square () const 
@@ -321,6 +325,20 @@ double Point<dim>::square () const
 };
 
 
+template <int dim>
+inline
+double Point<dim>::distance (const Point<dim> &p) const
+{
+  double sum=0;
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      const double diff=values[i]-p(i);
+      sum += diff*diff;
+    }
+  
+  return sqrt(sum);
+}
+
 
 template <int dim>
 inline

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.