YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThreeVector.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
20 
21 #ifndef yap_ThreeVector_h
22 #define yap_ThreeVector_h
23 
24 #include "fwd/ThreeVector.h"
25 
26 #include "Matrix.h"
27 #include "Vector.h"
28 
29 namespace yap {
30 
32 template <typename T>
33 constexpr ThreeVector<T> cross(const ThreeVector<T>& A, const ThreeVector<T>& B) noexcept
34 { return ThreeVector<T>({A[1]* B[2] - A[2]* B[1], A[2]* B[0] - A[0]* B[2], A[0]* B[1] - A[1]* B[0]}); }
35 
37 template<typename T>
38 constexpr SquareMatrix<T, 3> skewSymmetric(const ThreeVector<T> V) noexcept
39 {
40  return SquareMatrix<T, 3>({(T)0, -V[2], +V[1],
41  +V[2], (T)0, -V[0],
42  -V[1], +V[0], (T)0
43  });
44 }
45 
46 }
47 #endif
constexpr SquareMatrix< T, 3 > skewSymmetric(const ThreeVector< T > V) noexcept
skew symmetric matrix formed from a 3 vector
Definition: ThreeVector.h:38
constexpr ThreeVector< T > cross(const ThreeVector< T > &A, const ThreeVector< T > &B) noexcept
Definition: ThreeVector.h:33