dune-grid-glue 2.5-git
crossproduct.hh
Go to the documentation of this file.
1#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
2#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
3
4namespace Dune {
5namespace GridGlue {
6
12template <class T, int dim>
13static 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
Definition gridglue.hh:30
static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
compute cross product
Definition crossproduct.hh:13