38 #ifndef FCL_CCD_TBVMOTIONBOUNDVISITOR_INL_H
39 #define FCL_CCD_TBVMOTIONBOUNDVISITOR_INL_H
58 template <
typename S,
typename BV,
typename MotionT>
84 using S =
typename BV::S;
95 using S =
typename BV::S;
102 template<
typename BV>
106 using S =
typename BV::S;
113 template<
typename BV>
117 using S =
typename BV::S;
124 template <
typename S>
135 Vector3<S> c2 = visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0];
136 Vector3<S> c3 = visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1];
137 Vector3<S> c4 = visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] + visitor.bv.axis.col(1) * visitor.bv.l[1];
141 S cn_max = std::abs(c1.dot(visitor.n));
142 tmp = std::abs(c2.dot(visitor.n));
143 if(tmp > cn_max) cn_max = tmp;
144 tmp = std::abs(c3.dot(visitor.n));
145 if(tmp > cn_max) cn_max = tmp;
146 tmp = std::abs(c4.dot(visitor.n));
147 if(tmp > cn_max) cn_max = tmp;
150 S cmax = c1.squaredNorm();
151 tmp = c2.squaredNorm();
152 if(tmp > cmax) cmax = tmp;
153 tmp = c3.squaredNorm();
154 if(tmp > cmax) cmax = tmp;
155 tmp = c4.squaredNorm();
156 if(tmp > cmax) cmax = tmp;
160 S cxn_max = (c1.cross(visitor.n)).squaredNorm();
161 tmp = (c2.cross(visitor.n)).squaredNorm();
162 if(tmp > cxn_max) cxn_max = tmp;
163 tmp = (c3.cross(visitor.n)).squaredNorm();
164 if(tmp > cxn_max) cxn_max = tmp;
165 tmp = (c4.cross(visitor.n)).squaredNorm();
166 if(tmp > cxn_max) cxn_max = tmp;
167 cxn_max = sqrt(cxn_max);
170 S ratio =
std::min(1 - tf_t, dWdW_max);
172 S R_bound = 2 * (cn_max + cmax + cxn_max + 3 * visitor.bv.r) * ratio;
177 return R_bound + T_bound;
186 template <
typename S>
201 S c_proj_max = ((tf.linear() * visitor.bv.To).cross(axis)).squaredNorm();
203 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0])).cross(axis)).squaredNorm();
204 if(tmp > c_proj_max) c_proj_max = tmp;
205 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1])).cross(axis)).squaredNorm();
206 if(tmp > c_proj_max) c_proj_max = tmp;
207 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();
208 if(tmp > c_proj_max) c_proj_max = tmp;
210 c_proj_max = sqrt(c_proj_max);
212 S v_dot_n = axis.dot(visitor.n) * linear_vel;
213 S w_cross_n = (axis.cross(visitor.n)).norm() * angular_vel;
214 S origin_proj = ((tf.translation() - p).cross(axis)).norm();
216 S mu = v_dot_n + w_cross_n * (c_proj_max + visitor.bv.r + origin_proj);
227 template <
typename S>
242 S c_proj_max = ((tf.linear() * (visitor.bv.To - reference_p)).cross(angular_axis)).squaredNorm();
244 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(0) * visitor.bv.l[0] - reference_p)).cross(angular_axis)).squaredNorm();
245 if(tmp > c_proj_max) c_proj_max = tmp;
246 tmp = ((tf.linear() * (visitor.bv.To + visitor.bv.axis.col(1) * visitor.bv.l[1] - reference_p)).cross(angular_axis)).squaredNorm();
247 if(tmp > c_proj_max) c_proj_max = tmp;
248 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();
249 if(tmp > c_proj_max) c_proj_max = tmp;
251 c_proj_max = std::sqrt(c_proj_max);
253 S v_dot_n = linear_vel.dot(visitor.n);
254 S w_cross_n = (angular_axis.cross(visitor.n)).norm() * angular_vel;
255 S mu = v_dot_n + w_cross_n * (visitor.bv.r + c_proj_max);
263 template <
typename S>