OpenMEEG
dipole.h
Go to the documentation of this file.
1 // Project Name: OpenMEEG (http://openmeeg.github.io)
2 // © INRIA and ENPC under the French open source license CeCILL-B.
3 // See full copyright notice in the file LICENSE.txt
4 // If you make a copy of this file, you must either:
5 // - provide also LICENSE.txt and modify this header to refer to it.
6 // - replace this header by the LICENSE.txt content.
7 
8 #pragma once
9 
10 #include <matrix.h>
11 #include <vector.h>
12 #include <vect3.h>
13 
14 namespace OpenMEEG {
15 
16  class OPENMEEG_EXPORT Dipole {
17  public:
18 
19  Dipole(const Vector& V): r0(V(0),V(1),V(2)),q(V(3),V(4),V(5)) { }
20  Dipole(const Vect3& pos,const Vect3& moment): r0(pos),q(moment) { }
21 
22  Dipole(const unsigned i,const Matrix& M): r0(M(i,0),M(i,1),M(i,2)),q(M(i,3),M(i,4),M(i,5)) { }
23 
24  double potential(const Vect3& r) const {
25 
26  // V = q.(r-r0)/||r-r0||^3
27 
28  const Vect3& x = r-r0;
29  const double nrm2 = x.norm2();
30  return dotprod(q,x)/(nrm2*sqrt(nrm2));
31  }
32 
33  const Vect3& position() const { return r0; }
34  const Vect3& moment() const { return q; }
35 
36  private:
37 
38  const Vect3 r0;
39  const Vect3 q;
40  };
41 }
Dipole(const unsigned i, const Matrix &M)
Definition: dipole.h:22
double potential(const Vect3 &r) const
Definition: dipole.h:24
Dipole(const Vect3 &pos, const Vect3 &moment)
Definition: dipole.h:20
const Vect3 & position() const
Definition: dipole.h:33
const Vect3 & moment() const
Definition: dipole.h:34
Dipole(const Vector &V)
Definition: dipole.h:19
Matrix class Matrix class.
Definition: matrix.h:28
Vect3.
Definition: vect3.h:28
double norm2() const
Definition: vect3.h:64
double dotprod(const Vect3 &V1, const Vect3 &V2)
Definition: vect3.h:106