SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
TaoDeMatrix6Inl.h
1 /* Copyright (c) 2005 Arachi, Inc. and Stanford University. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject
9  * to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef _deMatrix6_inl
24 #define _deMatrix6_inl
25 
26 DE_MATH_API deFloat& deMatrix6::elementAt(const deInt i, const deInt j) {
27  return _mat3[(i / 3) * 2 + (j / 3)].elementAt(i % 3, j % 3);
28 }
29 DE_MATH_API const deFloat& deMatrix6::elementAt(const deInt i, const deInt j) const {
30  return _mat3[(i / 3) * 2 + (j / 3)].elementAt(i % 3, j % 3);
31 }
32 DE_MATH_API void deMatrix6::operator=(const deMatrix6& m) {
33  _mat3[0] = m._mat3[0]; _mat3[1] = m._mat3[1];
34  _mat3[2] = m._mat3[2]; _mat3[3] = m._mat3[3];
35 }
36 DE_MATH_API void deMatrix6::zero() {
37  _mat3[0].zero(); _mat3[1].zero();
38  _mat3[2].zero(); _mat3[3].zero();
39 }
40 DE_MATH_API void deMatrix6::identity() {
41  _mat3[0].identity(); _mat3[1].zero();
42  _mat3[2].zero(); _mat3[3].identity();
43 }
44 DE_MATH_API void deMatrix6::negate(const deMatrix6& m) {
45  _mat3[0].negate(m._mat3[0]); _mat3[1].negate(m._mat3[1]);
46  _mat3[2].negate(m._mat3[2]); _mat3[3].negate(m._mat3[3]);
47 }
48 DE_MATH_API void deMatrix6::add(const deMatrix6& m1, const deMatrix6& m2) {
49  _mat3[0].add(m1._mat3[0], m2._mat3[0]); _mat3[1].add(m1._mat3[1], m2._mat3[1]);
50  _mat3[2].add(m1._mat3[2], m2._mat3[2]); _mat3[3].add(m1._mat3[3], m2._mat3[3]);
51 }
52 DE_MATH_API void deMatrix6::subtract(const deMatrix6& m1, const deMatrix6& m2) {
53  _mat3[0].subtract(m1._mat3[0], m2._mat3[0]); _mat3[1].subtract(m1._mat3[1], m2._mat3[1]);
54  _mat3[2].subtract(m1._mat3[2], m2._mat3[2]); _mat3[3].subtract(m1._mat3[3], m2._mat3[3]);
55 }
56 DE_MATH_API void deMatrix6::multiply(const deMatrix6& m, const deFloat s) {
57  _mat3[0].multiply(m._mat3[0], s); _mat3[1].multiply(m._mat3[1], s);
58  _mat3[2].multiply(m._mat3[2], s); _mat3[3].multiply(m._mat3[3], s);
59 }
60 DE_MATH_API void deMatrix6::operator+=(const deMatrix6& m) {
61  _mat3[0] += m._mat3[0]; _mat3[1] += m._mat3[1];
62  _mat3[2] += m._mat3[2]; _mat3[3] += m._mat3[3];
63 }
64 DE_MATH_API void deMatrix6::operator-=(const deMatrix6& m) {
65  _mat3[0] -= m._mat3[0]; _mat3[1] -= m._mat3[1];
66  _mat3[2] -= m._mat3[2]; _mat3[3] -= m._mat3[3];
67 }
68 DE_MATH_API void deMatrix6::operator*=(const deFloat s) {
69  _mat3[0] *= s; _mat3[1] *= s;
70  _mat3[2] *= s; _mat3[3] *= s;
71 }
72 DE_MATH_API void deMatrix6::transpose(const deMatrix6& m) {
73  _mat3[0].transpose(m._mat3[0]); _mat3[1].transpose(m._mat3[2]);
74  _mat3[2].transpose(m._mat3[1]); _mat3[3].transpose(m._mat3[3]);
75 }
76 DE_MATH_API void deMatrix6::set(const deTransform& t) {
77  _mat3[0] = t.rotation();
78  _mat3[1].zero();
79  _mat3[2].crossMultiply(t.translation(), _mat3[0]);
80  _mat3[3] = _mat3[0];
81 }
82 
83 #endif // _deMatrix6_inl
DE_MATH_API void transpose(const deMatrix3 &m)
this = m^T
Definition: TaoDeMatrix3Inl.h:50
DE_MATH_API void operator-=(const deMatrix6 &m)
this -= m
Definition: TaoDeMatrix6Inl.h:64
DE_MATH_API void subtract(const deMatrix3 &m1, const deMatrix3 &m2)
this = m1 - m2
Definition: TaoDeMatrix3Inl.h:33
deFloat & elementAt(const deInt i, const deInt j)
Definition: TaoDeMatrix3.h:56
DE_MATH_API void identity()
this = identity matrix
Definition: TaoDeMatrix3Inl.h:30
DE_MATH_API void multiply(const deMatrix6 &m, const deFloat s)
this[i] = m[i] * s
Definition: TaoDeMatrix6Inl.h:56
DE_MATH_API void operator=(const deMatrix6 &m)
this = m
Definition: TaoDeMatrix6Inl.h:32
DE_MATH_API void zero()
this = zero matrix
Definition: TaoDeMatrix3Inl.h:29
DE_MATH_API void add(const deMatrix3 &m1, const deMatrix3 &m2)
this = m1 + m2
Definition: TaoDeMatrix3Inl.h:32
DE_MATH_API deMatrix3 & rotation()
Definition: TaoDeTransformInl.h:26
Transformation class using rotational matrixThis class consists of a matrix for rotation and a vector...
Definition: TaoDeTransform.h:32
DE_MATH_API void multiply(const deMatrix3 &m1, const deMatrix3 &m2)
this = m1 * m2
Definition: TaoDeMatrix3Inl.h:34
DE_MATH_API void zero()
this = zero matrix
Definition: TaoDeMatrix6Inl.h:36
DE_MATH_API void subtract(const deMatrix6 &m1, const deMatrix6 &m2)
this = m1 - m2
Definition: TaoDeMatrix6Inl.h:52
DE_MATH_API void operator+=(const deMatrix6 &m)
this += m
Definition: TaoDeMatrix6Inl.h:60
DE_MATH_API void operator*=(const deFloat s)
this[i] -= s
Definition: TaoDeMatrix6Inl.h:68
DE_MATH_API void negate(const deMatrix3 &m)
this = -m
Definition: TaoDeMatrix3Inl.h:31
DE_MATH_API void set(const deTransform &t)
this = X where X = [R 0; dxR R]
Definition: TaoDeMatrix6Inl.h:76
6x6 matrix classThis class consists of four 3x3 matrices.
Definition: TaoDeMatrix6.h:33
DE_MATH_API void negate(const deMatrix6 &m)
this = -m
Definition: TaoDeMatrix6Inl.h:44
DE_MATH_API void crossMultiply(const deVector3 &v, const deMatrix3 &m)
this = (v x) * m
Definition: TaoDeMatrix3Inl.h:52
DE_MATH_API void transpose(const deMatrix6 &m)
this = m^T
Definition: TaoDeMatrix6Inl.h:72
DE_MATH_API void add(const deMatrix6 &m1, const deMatrix6 &m2)
this = m1 + m2
Definition: TaoDeMatrix6Inl.h:48
DE_MATH_API deVector3 & translation()
Definition: TaoDeTransformInl.h:28
DE_MATH_API deFloat & elementAt(const deInt i, const deInt j)
Definition: TaoDeMatrix6Inl.h:26
DE_MATH_API void identity()
this = identity matrix
Definition: TaoDeMatrix6Inl.h:40