38 #ifndef FCL_CCD_TBVMOTIONBOUNDVISITOR_INL_H 39 #define FCL_CCD_TBVMOTIONBOUNDVISITOR_INL_H 41 #include "fcl/math/motion/tbv_motion_bound_visitor.h" 48 TBVMotionBoundVisitor<BV>::TBVMotionBoundVisitor(
49 const BV& bv_,
const Vector3<typename BV::S>& n_)
56 template <
typename S,
typename BV,
typename MotionT>
80 using S =
typename BV::S;
91 using S =
typename BV::S;
102 using S =
typename BV::S;
109 template<
typename BV>
113 using S =
typename BV::S;
120 template <
typename S>
127 S T_bound = motion.computeTBound(visitor.n);
128 S tf_t = motion.getCurrentTime();
130 Vector3<S> c1 = visitor.bv.To;
131 Vector3<S> c2 = visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0];
132 Vector3<S> c3 = visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1];
133 Vector3<S> c4 = visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] + visitor.bv.axis.col(1) * visitor.bv.l[1];
137 S cn_max = std::abs(c1.dot(visitor.n));
138 tmp = std::abs(c2.dot(visitor.n));
139 if(tmp > cn_max) cn_max = tmp;
140 tmp = std::abs(c3.dot(visitor.n));
141 if(tmp > cn_max) cn_max = tmp;
142 tmp = std::abs(c4.dot(visitor.n));
143 if(tmp > cn_max) cn_max = tmp;
146 S cmax = c1.squaredNorm();
147 tmp = c2.squaredNorm();
148 if(tmp > cmax) cmax = tmp;
149 tmp = c3.squaredNorm();
150 if(tmp > cmax) cmax = tmp;
151 tmp = c4.squaredNorm();
152 if(tmp > cmax) cmax = tmp;
156 S cxn_max = (c1.cross(visitor.n)).squaredNorm();
157 tmp = (c2.cross(visitor.n)).squaredNorm();
158 if(tmp > cxn_max) cxn_max = tmp;
159 tmp = (c3.cross(visitor.n)).squaredNorm();
160 if(tmp > cxn_max) cxn_max = tmp;
161 tmp = (c4.cross(visitor.n)).squaredNorm();
162 if(tmp > cxn_max) cxn_max = tmp;
163 cxn_max = sqrt(cxn_max);
165 S dWdW_max = motion.computeDWMax();
166 S ratio = std::min(1 - tf_t, dWdW_max);
168 S R_bound = 2 * (cn_max + cmax + cxn_max + 3 * visitor.bv.r) * ratio;
173 return R_bound + T_bound;
182 template <
typename S>
192 const Vector3<S>& axis = motion.getAxis();
193 S linear_vel = motion.getLinearVelocity();
194 S angular_vel = motion.getAngularVelocity();
195 const Vector3<S>& p = motion.getAxisOrigin();
197 S c_proj_max = ((tf.linear() * visitor.bv.To).cross(axis)).squaredNorm();
199 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0])).cross(axis)).squaredNorm();
200 if(tmp > c_proj_max) c_proj_max = tmp;
201 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1])).cross(axis)).squaredNorm();
202 if(tmp > c_proj_max) c_proj_max = tmp;
203 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] + visitor.bv.axis.col(1) * visitor.bv.l[1])).cross(axis)).squaredNorm();
204 if(tmp > c_proj_max) c_proj_max = tmp;
206 c_proj_max = sqrt(c_proj_max);
208 S v_dot_n = axis.dot(visitor.n) * linear_vel;
209 S w_cross_n = (axis.cross(visitor.n)).norm() * angular_vel;
210 S origin_proj = ((tf.translation() - p).cross(axis)).norm();
212 S mu = v_dot_n + w_cross_n * (c_proj_max + visitor.bv.r + origin_proj);
223 template <
typename S>
233 const Vector3<S>& reference_p = motion.getReferencePoint();
234 const Vector3<S>& angular_axis = motion.getAngularAxis();
235 S angular_vel = motion.getAngularVelocity();
236 const Vector3<S>& linear_vel = motion.getLinearVelocity();
238 S c_proj_max = ((tf.linear() * (visitor.bv.To - reference_p)).cross(angular_axis)).squaredNorm();
240 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] - reference_p)).cross(angular_axis)).squaredNorm();
241 if(tmp > c_proj_max) c_proj_max = tmp;
242 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1] - reference_p)).cross(angular_axis)).squaredNorm();
243 if(tmp > c_proj_max) c_proj_max = tmp;
244 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] + visitor.bv.axis.col(1) * visitor.bv.l[1] - reference_p)).cross(angular_axis)).squaredNorm();
245 if(tmp > c_proj_max) c_proj_max = tmp;
247 c_proj_max = std::sqrt(c_proj_max);
249 S v_dot_n = linear_vel.dot(visitor.n);
250 S w_cross_n = (angular_axis.cross(visitor.n)).norm() * angular_vel;
251 S mu = v_dot_n + w_cross_n * (visitor.bv.r + c_proj_max);
259 template <
typename S>
266 return motion.getVelocity().dot(visitor.n);
Definition: tbv_motion_bound_visitor-inl.h:57
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
Definition: bv_motion_bound_visitor.h:51
void getCurrentTransform(Transform3< S > &tf_) const
Get the rotation and translation in current step.
Definition: interp_motion-inl.h:156
Definition: bv_motion_bound_visitor.h:57
void getCurrentTransform(Transform3< S > &tf_) const
Get the rotation and translation in current step.
Definition: screw_motion-inl.h:125
Definition: bv_motion_bound_visitor.h:48
Linear interpolation motion Each Motion is assumed to have constant linear velocity and angular veloc...
Definition: bv_motion_bound_visitor.h:54
Definition: tbv_motion_bound_visitor.h:65
Definition: bv_motion_bound_visitor.h:45