1 #ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
2 #define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
3 
4 namespace Dune {
5 namespace GridGlue {
6 
7 /**
8  * \brief compute cross product
9  *
10  * \return <code>a × b</code>
11  */
12 template <class T, int dim>
crossProduct(const Dune::FieldVector<T,dim> & a,const Dune::FieldVector<T,dim> & b)13 static Dune::FieldVector<T,dim> crossProduct(const Dune::FieldVector<T,dim>& a,
14                                              const Dune::FieldVector<T,dim>& b)
15 {
16   if (dim!=3)
17     DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension " << dim);
18 
19   Dune::FieldVector<T,dim> c;
20   c[0] = a[1]*b[2] - a[2]*b[1];
21   c[1] = a[2]*b[0] - a[0]*b[2];
22   c[2] = a[0]*b[1] - a[1]*b[0];
23 
24   return c;
25 }
26 
27 } /* namespace GridGlue */
28 } /* namespace Dune */
29 
30 #endif
31