12 Vec3<T> cp_pos_in_height_map = cp_pos - _left_corner_loc;
13 if ((0 < cp_pos_in_height_map[0]) && (cp_pos_in_height_map[0] < _x_max)) {
14 if ((0 < cp_pos_in_height_map[1]) && (cp_pos_in_height_map[1] < _y_max)) {
15 int x_idx = floor(cp_pos_in_height_map[0] / _grid);
16 int y_idx = floor(cp_pos_in_height_map[1] / _grid);
21 vec1[2] = _height_map(x_idx + 1, y_idx + 1) - _height_map(x_idx, y_idx);
26 vec2[2] = _height_map(x_idx + 1, y_idx) - _height_map(x_idx, y_idx + 1);
31 Vec3<T> normal = vec2.cross(vec1);
33 Vec3<T> y_axis = normal.cross(vec2);
35 cp_frame.template block<3, 1>(0, 0) = vec2;
36 cp_frame.template block<3, 1>(0, 1) = y_axis;
37 cp_frame.template block<3, 1>(0, 2) = normal;
40 T height_ave = 0.25 * _height_map(x_idx, y_idx) +
41 0.25 * _height_map(x_idx, y_idx + 1) +
42 0.25 * _height_map(x_idx + 1, y_idx) +
43 0.25 * _height_map(x_idx + 1, y_idx + 1);
46 middle_pt[0] = _grid * x_idx + 0.5 * _grid;
47 middle_pt[1] = _grid * y_idx + 0.5 * _grid;
48 middle_pt[2] = height_ave;
51 cp_frame.transpose() * (cp_pos_in_height_map - middle_pt);
53 if (local_diff[2] < 0.) {
54 penetration = local_diff[2];
virtual bool ContactDetection(const Vec3< T > &cp_pos, T &penetration, Mat3< T > &cp_frame)
typename Eigen::Matrix< T, 3, 3 > Mat3
typename Eigen::Matrix< T, 3, 1 > Vec3
Collision logic for a mesh.