check whether the contact happens or not cp_frame let you know which direction is normal (z) and which directions are x and y. The frame is basically contact coordinate w.r.t global.
14 bool inside_box(
true);
16 for (
size_t i(0); i < 3; ++i) {
18 if (center2cp_local[i] >
_size[i] / 2.) {
22 else if (center2cp_local[i] < -
_size[i] / 2.) {
27 err[i] =
_size[i] / 2. - std::abs(center2cp_local[i]);
32 if (err[2] < std::min(err[0], err[1])) {
33 if (center2cp_local[2] > 0.) {
38 penetration = -err[2];
39 }
else if (err[1] < std::min(err[0], err[2])) {
40 if (center2cp_local[1] > 0.) {
42 cp_frame.template block<3, 1>(0, 0) =
45 cp_frame.template block<3, 1>(0, 1) =
48 cp_frame.template block<3, 1>(0, 2) =
52 cp_frame.template block<3, 1>(0, 0) =
55 cp_frame.template block<3, 1>(0, 1) =
58 cp_frame.template block<3, 1>(0, 2) =
61 penetration = -err[1];
63 if (center2cp_local[0] > 0.) {
65 cp_frame.template block<3, 1>(0, 0) =
68 cp_frame.template block<3, 1>(0, 1) =
71 cp_frame.template block<3, 1>(0, 2) =
75 cp_frame.template block<3, 1>(0, 0) =
78 cp_frame.template block<3, 1>(0, 1) =
81 cp_frame.template block<3, 1>(0, 2) =
84 penetration = -err[0];
typename Eigen::Matrix< T, 3, 1 > Vec3