Skip to content

Commit f6d80a8

Browse files
committed
CPatch: add helper to project patch onto original shapes
1 parent d57118a commit f6d80a8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/hpp/fcl/collision_data.h

+20
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,26 @@ struct HPP_FCL_DLLAPI ContactPatch {
593593
return point;
594594
}
595595

596+
/// @brief Get the i-th point of the set, projected back onto the first shape
597+
/// of the collision pair. This point is expressed in the 3D reference frame.
598+
Vec3f getPointShape1(const size_t i) const {
599+
Vec3f point(0, 0, 0);
600+
point.head<2>() = this->point(i);
601+
point =
602+
tf.transform(point) - (this->penetration_depth / 2) * this->getNormal();
603+
return point;
604+
}
605+
606+
/// @brief Get the i-th point of the set, projected back onto the first shape
607+
/// of the collision pair.
608+
Vec3f getPointShape2(const size_t i) const {
609+
Vec3f point(0, 0, 0);
610+
point.head<2>() = this->point(i);
611+
point =
612+
tf.transform(point) + (this->penetration_depth / 2) * this->getNormal();
613+
return point;
614+
}
615+
596616
/// @brief Getter for the 2D points in the set.
597617
Polygon& points() { return this->m_points; }
598618

python/contact_patch.cc

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ void exposeContactPatchAPI() {
7777
.DEF_CLASS_FUNC(ContactPatch, getNormal)
7878
.DEF_CLASS_FUNC(ContactPatch, addPoint)
7979
.DEF_CLASS_FUNC(ContactPatch, getPoint)
80+
.DEF_CLASS_FUNC(ContactPatch, getPointShape1)
81+
.DEF_CLASS_FUNC(ContactPatch, getPointShape2)
8082
.DEF_CLASS_FUNC(ContactPatch, clear)
8183
.DEF_CLASS_FUNC(ContactPatch, isSame);
8284
}

0 commit comments

Comments
 (0)