37 #ifndef FCL_NARROWPHASE_DETAIL_SPHERECYLINDER_INL_H 38 #define FCL_NARROWPHASE_DETAIL_SPHERECYLINDER_INL_H 45 extern template FCL_EXPORT
bool 47 const Transform3<double>& X_FS,
49 const Transform3<double>& X_FC,
50 std::vector<ContactPoint<double>>* contacts);
54 extern template FCL_EXPORT
bool 56 const Transform3<double>& X_FS,
58 const Transform3<double>& X_FC,
59 double*
distance, Vector3<double>* p_FSc,
60 Vector3<double>* p_FCs);
81 assert(p_CN_ptr !=
nullptr);
88 const S half_height = height / 2;
89 if (p_CQ(2) > half_height) {
91 p_CN(2) = half_height;
92 }
else if (p_CQ(2) < -half_height) {
94 p_CN(2) = -half_height;
99 S squared_distance = r_CQ.dot(r_CQ);
100 if (squared_distance > radius * radius) {
103 r_CQ *= radius / sqrt(squared_distance);
113 template <
typename S>
133 const S p_SN_squared_dist = p_SN_C.squaredNorm();
136 if (p_SN_squared_dist > r_s * r_s)
141 if (contacts !=
nullptr) {
159 if (S_is_outside && p_SN_squared_dist > eps * eps) {
168 const S d_NS = sqrt(p_SN_squared_dist);
169 n_SC_C = p_SN_C / d_NS;
171 p_CP = p_CN + n_SC_C * (depth * 0.5);
175 const S& h = cylinder.
lz;
176 const S face_distance = p_CS(2) >= 0 ? h / 2 - p_CS(2) : p_CS(2) + h / 2;
183 const S d_CS_xy = n_SB_xy.norm();
184 const S barrel_distance = cylinder.
radius - d_CS_xy;
191 if (barrel_distance < face_distance - eps) {
195 n_SC_C << -n_SB_xy(0) / d_CS_xy, -n_SB_xy(1) / d_CS_xy, 0;
196 depth = r_s + barrel_distance;
197 p_CP = p_CS + n_SC_C * ((r_s - barrel_distance) / 2);
203 depth = r_s + cylinder.
radius;
204 p_CP = p_CS + n_SC_C * ((r_s - barrel_distance) / 2);
213 n_SC_C(2) = p_CS(2) >= 0 ? -1 : 1;
214 depth = face_distance +
r_s;
215 p_CP = p_CS + n_SC_C * ((r_s - face_distance) / 2);
218 contacts->emplace_back(X_FC.linear() * n_SC_C, X_FC * p_CP, depth);
225 template <
typename S>
249 const S p_NS_squared_dist = p_NS_C.squaredNorm();
250 if (p_NS_squared_dist > r_s * r_s) {
254 if (distance || p_FCs || p_FSc)
255 d = sqrt(p_NS_squared_dist);
256 if (distance !=
nullptr)
258 if (p_FCs !=
nullptr)
259 *p_FCs = X_FC * p_CN;
260 if (p_FSc !=
nullptr) {
261 const Vector3<S> p_CSc = p_CS - (p_NS_C * r_s / d);
262 *p_FSc = X_FC * p_CSc;
269 if (distance !=
nullptr) *distance = -1;
276 #endif // FCL_NARROWPHASE_DETAIL_SPHERECYLINDER_INL_H
S radius
Radius of the cylinder.
Eigen::Transform< S, 3, Eigen::Isometry > Transform3
static constexpr Real eps()
Returns ε for the precision of the underlying scalar type.
Eigen::Matrix< S, 3, 1 > Vector3
bool nearestPointInCylinder(const S &height, const S &radius, const Vector3< S > &p_CQ, Vector3< S > *p_CN_ptr)
Eigen::Matrix< S, 2, 1 > Vector2
template void distance(DistanceTraversalNodeBase< double > *node, BVHFrontList *front_list, int qsize)
template FCL_EXPORT bool sphereCylinderDistance(const Sphere< double > &sphere, const Transform3< double > &X_FS, const Cylinder< double > &cylinder, const Transform3< double > &X_FC, double *distance, Vector3< double > *p_FSc, Vector3< double > *p_FCs)
template FCL_EXPORT bool sphereCylinderIntersect(const Sphere< double > &sphere, const Transform3< double > &X_FS, const Cylinder< double > &cylinder, const Transform3< double > &X_FC, std::vector< ContactPoint< double >> *contacts)
S radius
Radius of the sphere.
Center at zero point sphere.
template class FCL_EXPORT Cylinder< double >
template class FCL_EXPORT Sphere< double >