SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
TaoDeFrameInl.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 _deFrame_inl
24 #define _deFrame_inl
25 
26 DE_MATH_API void deFrame::identity() { ori_quat_.identity(); translation_.zero(); }
27 DE_MATH_API void deFrame::operator=(const deFrame & f) { ori_quat_ = f.ori_quat_; translation_ = f.translation_; }
29 DE_MATH_API void deFrame::multiply(const deFrame& f1, const deFrame& f2) {
30  ori_quat_.multiply(f1.rotation(), f2.rotation());
31  translation_.multiply(f1.rotation(), f2.translation());
32  translation_ += f1.translation();
33 }
35 // = ~[r1,p1][r2,p2] = [~r1, -(~r1*p1)][r2,p2] = [~r1*r2, ~r1*p2 - (~r1*p1)]
36 // = [~r1*r2, ~r1*(p2-p1)]
37 DE_MATH_API void deFrame::inversedMultiply(const deFrame& f1, const deFrame& f2) {
38  deVector3 p;
39  p.subtract(f2.translation(), f1.translation());
40  translation_.inversedMultiply(f1.rotation(), p);
41  ori_quat_.inversedMultiply(f1.rotation(), f2.rotation());
42 }
44 // = [r1,p1]~[r2,p2] = [r1,p1][~r2, -(~r2*p2)] = [r1*~r2, -r1*(~r2*p2) + p1]
45 // = [r1*~r2, -r1*~r2*p2 + p1]
46 DE_MATH_API void deFrame::multiplyInversed(const deFrame& f1, const deFrame& f2) {
47  ori_quat_.multiplyInversed(f1.rotation(), f2.rotation());
48  translation_.multiply(ori_quat_, f2.translation());
49  translation_.subtract(f1.translation(), translation_);
50 }
52 DE_MATH_API void deFrame::inverse(const deFrame& f) {
53  ori_quat_.inverse(f.rotation());
54  translation_.multiply(ori_quat_, f.translation());
55  translation_.negate(translation_);
56 }
57 DE_MATH_API void deFrame::set(const deTransform& t) { ori_quat_.set(t.rotation()); translation_ = t.translation(); }
58 DE_MATH_API void deFrame::set(const deQuaternion& q, const deVector3& v) { ori_quat_ = q; translation_ = v; }
59 
60 #endif // _deFrame_inl
61 
DE_MATH_API void operator=(const deFrame &f)
this = f
Definition: TaoDeFrameInl.h:27
3x1 vector classThis is a C++ wrapper class of deVector3f.
Definition: TaoDeVector3.h:32
DE_MATH_API void identity()
this = identity matrix
Definition: TaoDeFrameInl.h:26
DE_MATH_API void multiply(const deFrame &f1, const deFrame &f2)
this = f1 * f2 = [r1,p1][r2,p2] = [r1*r2, r1*p2 + p1]
Definition: TaoDeFrameInl.h:29
deQuaternion & rotation()
Definition: TaoDeFrame.h:49
DE_MATH_API void inversedMultiply(const deFrame &f1, const deFrame &f2)
this = f1^-1 * f2
Definition: TaoDeFrameInl.h:37
DE_MATH_API void inversedMultiply(const deTransform &t, const deVector3 &v)
this = ~[r,p]*v = [~r, -(~r*p)]*v = ~r*v -~r*p = ~r*(v-p)
Definition: TaoDeVector3Inl.h:58
DE_MATH_API void inversedMultiply(const deQuaternion &q1, const deQuaternion &q2)
this = q1^-1 * q2
Definition: TaoDeQuaternionInl.h:48
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 multiplyInversed(const deFrame &f1, const deFrame &f2)
this = f1 * f2^-1
Definition: TaoDeFrameInl.h:46
Quaternion classThis is a C++ wrapper class of deQuaternionf.
Definition: TaoDeQuaternion.h:35
Transformation class using quaternionThis class consists of a quaternion for rotation and a vector fo...
Definition: TaoDeFrame.h:36
deVector3 & translation()
Definition: TaoDeFrame.h:53
DE_MATH_API void subtract(const deVector3 &v1, const deVector3 &v2)
this = v1 - v2
Definition: TaoDeVector3Inl.h:47
DE_MATH_API void identity()
this = (0, 0, 0, 1)
Definition: TaoDeQuaternionInl.h:33
DE_MATH_API void set(const deTransform &t)
this = t
Definition: TaoDeFrameInl.h:57
DE_MATH_API void multiply(const deQuaternion &q1, const deQuaternion &q2)
this = q1 * q2
Definition: TaoDeQuaternionInl.h:47
DE_MATH_API deVector3 & translation()
Definition: TaoDeTransformInl.h:28
DE_MATH_API void multiplyInversed(const deQuaternion &q1, const deQuaternion &q2)
this = q1 * q2^-1
Definition: TaoDeQuaternionInl.h:49
DE_MATH_API void inverse(const deFrame &f)
this = f^-1
Definition: TaoDeFrameInl.h:52
DE_MATH_API void zero()
this = 0
Definition: TaoDeVector3Inl.h:38
DE_MATH_API void inverse(const deQuaternion &q)
this = q^-1
Definition: TaoDeQuaternionInl.h:44
DE_MATH_API void negate(const deVector3 &v)
this = -v
Definition: TaoDeVector3Inl.h:45
DE_MATH_API void multiply(const deVector3 &v1, const deVector3 &v2)
this[i] = v1[i] * v2[i]
Definition: TaoDeVector3Inl.h:48
DE_MATH_API void set(const deMatrix3 &m)
this = m
Definition: TaoDeQuaternionInl.h:37