dune-grid-glue  2.9
crossproduct.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
3 #ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
4 #define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
5 
6 namespace Dune {
7 namespace GridGlue {
8 
14 template <class T, int dim>
15 static Dune::FieldVector<T,dim> crossProduct(const Dune::FieldVector<T,dim>& a,
16  const Dune::FieldVector<T,dim>& b)
17 {
18  if (dim!=3)
19  DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension " << dim);
20 
21  Dune::FieldVector<T,dim> c;
22  c[0] = a[1]*b[2] - a[2]*b[1];
23  c[1] = a[2]*b[0] - a[0]*b[2];
24  c[2] = a[0]*b[1] - a[1]*b[0];
25 
26  return c;
27 }
28 
29 } /* namespace GridGlue */
30 } /* namespace Dune */
31 
32 #endif
Definition: gridglue.hh:37
static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
compute cross product
Definition: crossproduct.hh:15