FCL  0.6.0
Flexible Collision Library
translation_motion-inl.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
38 #ifndef FCL_CCD_TRANSLATIONMOTION_INL_H
39 #define FCL_CCD_TRANSLATIONMOTION_INL_H
40 
41 #include "fcl/math/motion/translation_motion.h"
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 class TranslationMotion<double>;
49 
50 //==============================================================================
51 template <typename S>
53  const Transform3<S>& tf1, const Transform3<S>& tf2)
54  : MotionBase<S>(),
55  rot(tf1.linear()),
56  trans_start(tf1.translation()),
57  trans_range(tf2.translation() - tf1.translation()),
58  tf(tf1)
59 {
60  // Do nothing
61 }
62 
63 //==============================================================================
64 template <typename S>
66  const Matrix3<S>& R, const Vector3<S>& T1, const Vector3<S>& T2)
67  : MotionBase<S>(), tf(Transform3<S>::Identity())
68 {
69  rot = R;
70  trans_start = T1;
71  trans_range = T2 - T1;
72  tf.linear() = R;
73  tf.translation() = trans_start;
74 }
75 
76 //==============================================================================
77 template <typename S>
79 {
80  if(dt > 1)
81  dt = 1;
82 
83  tf.linear() = rot.toRotationMatrix(); // TODO(JS): necessary?
84  tf.translation() = trans_start + trans_range * dt;
85 
86  return true;
87 }
88 
89 //==============================================================================
90 template <typename S>
92  const BVMotionBoundVisitor<S>& mb_visitor) const
93 {
94  return mb_visitor.visit(*this);
95 }
96 
97 //==============================================================================
98 template <typename S>
100  const TriangleMotionBoundVisitor<S>& mb_visitor) const
101 {
102  return mb_visitor.visit(*this);
103 }
104 
105 //==============================================================================
106 template <typename S>
107 void TranslationMotion<S>::getCurrentTransform(Transform3<S>& tf_) const
108 {
109  tf_ = tf;
110 }
111 
112 //==============================================================================
113 template <typename S>
115 {
116  // Do nothing
117  // TODO(JS): Not implemented?
118 }
119 
120 //==============================================================================
121 template <typename S>
122 Vector3<S> TranslationMotion<S>::getVelocity() const
123 {
124  return trans_range;
125 }
126 
127 } // namespace fcl
128 
129 #endif
Definition: motion_base.h:52
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
Definition: bv_motion_bound_visitor.h:57
TranslationMotion(const Transform3< S > &tf1, const Transform3< S > &tf2)
Construct motion from intial and goal transform.
Definition: translation_motion-inl.h:52
bool integrate(S dt) const override
Integrate the motion from 0 to dt.
Definition: translation_motion-inl.h:78
S computeMotionBound(const BVMotionBoundVisitor< S > &mb_visitor) const override
Compute the motion bound for a bounding volume, given the closest direction n between two query objec...
Definition: translation_motion-inl.h:91
Definition: bv_motion_bound_visitor.h:45
Compute the motion bound for a bounding volume, given the closest direction n between two query objec...
Definition: bv_motion_bound_visitor.h:62
Definition: taylor_matrix.h:48
Definition: taylor_vector.h:48