Robotics Library  0.7.0
MatrixBaseAddons.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MATH_MATRIXBASEADDONS_H
28 #define RL_MATH_MATRIXBASEADDONS_H
29 
30 Matrix<Scalar, 3, 1>
31 cross3() const
32 {
33  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
34  Matrix<Scalar, 3, 1> res;
35  res.x() = (this->derived()(2, 1) - this->derived()(1, 2)) / Scalar(2);
36  res.y() = (this->derived()(0, 2) - this->derived()(2, 0)) / Scalar(2);
37  res.z() = (this->derived()(1, 0) - this->derived()(0, 1)) / Scalar(2);
38  return res;
39 }
40 
41 Matrix<Scalar, 3, 3>
42 cross33() const
43 {
44  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3)
45  Matrix<Scalar, 3, 3> res;
46  res(0, 0) = 0;
47  res(0, 1) = -this->derived().z();
48  res(0, 2) = this->derived().y();
49  res(1, 0) = this->derived().z();
50  res(1, 1) = 0;
51  res(1, 2) = -this->derived().x();
52  res(2, 0) = -this->derived().y();
53  res(2, 1) = this->derived().x();
54  res(2, 2) = 0;
55  return res;
56 }
57 
58 Matrix<Scalar, 6, 1>
59 voigt6() const
60 {
61  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
62  Matrix<Scalar, 6, 1> res;
63  res(0) = this->derived()(0, 0);
64  res(1) = this->derived()(1, 1);
65  res(2) = this->derived()(2, 2);
66  res(3) = (this->derived()(1, 2) + this->derived()(2, 1)) / Scalar(2);
67  res(4) = (this->derived()(0, 2) + this->derived()(2, 0)) / Scalar(2);
68  res(5) = (this->derived()(0, 1) + this->derived()(1, 0)) / Scalar(2);
69  return res;
70 }
71 
72 Matrix<Scalar, 3, 3>
73 voigt33() const
74 {
75  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 6)
76  Matrix<Scalar, 3, 3> res;
77  res(0, 0) = this->derived()(0);
78  res(0, 1) = this->derived()(5);
79  res(0, 2) = this->derived()(4);
80  res(1, 0) = this->derived()(5);
81  res(1, 1) = this->derived()(1);
82  res(1, 2) = this->derived()(3);
83  res(2, 0) = this->derived()(4);
84  res(2, 1) = this->derived()(3);
85  res(2, 2) = this->derived()(2);
86  return res;
87 }
88 
89 #endif // RL_MATH_MATRIXBASEADDONS_H
voigt33
Matrix< Scalar, 3, 3 > voigt33() const
Definition: MatrixBaseAddons.h:73
cross33
Matrix< Scalar, 3, 3 > cross33() const
Definition: MatrixBaseAddons.h:42
voigt6
Matrix< Scalar, 6, 1 > voigt6() const
Definition: MatrixBaseAddons.h:59
cross3
Matrix< Scalar, 3, 1 > cross3() const
Definition: MatrixBaseAddons.h:31