14 double dx = u.
x() -
v.x();
15 double dy = u.y() -
v.y();
16 double dz = u.z() -
v.z();
17 return sqrt(dx*dx + dy*dy + dz*dz);
37 for (
int i = 0; i < halfM*halfM; i++)
46 for (
int i = 0; i < Nc; i++)
61 colli_map.push_back(temp);
62 colli_map.push_back(temp);
63 colli_map.push_back(temp);
66 for(
int i = 0; i <
divide_; i++)
70 for(
int j = 0; j < 3; j++)
76 theta = (j * 3 + 1) * 18.0 / 180.0 *
F_PI;
81 theta = (j * 3 + 2) * 18.0 / 180.0 *
F_PI;
86 theta = (j * 3 + 3)* 18.0 / 180.0 *
F_PI;
90 if(theta >
F_PI - 75.0 / 180.0 *
F_PI)
99 vector<lld> &result_map)
104 bool change_flag =
false;
108 for (
int i = 0; i < Nd; i++)
123 std::vector<lld> &result_map)
133 std::vector<GeoV3>& output)
146 for (
int j = 0; j < 3; j++)
148 for (
int i = 0; i <
divide_; i++)
152 theta = (j * 3 + 1) * 18.0 / 180.0 *
F_PI;
155 if (i > 19 && i < 40)
157 theta = (j * 3 + 2) * 18.0 / 180.0 *
F_PI;
162 theta = (j * 3 + 3) * 18.0 / 180.0 *
F_PI;
166 phi = (i % 20) * 18.0 / 180.0 *
F_PI;
184 for (
int i = 0; i < 3; i++)
186 angle_state[i] |= colli_map[i];
192 if (colli_map[0] == (
lld) 0 && colli_map[1] == (
lld) 0 && colli_map[2] == (
lld) 0)
199 for(
int j = 0; j < 62; j++)
203 for(
int i = 0; i < 3; i++)
212 if((colli_map[i] & mask) == 0)
224 std::vector<Eigen::Vector3d> feasible_eef_directions;
226 for(
int i = 0; i <
divide_; i++)
230 for(
int j = 0; j < 3; j++)
233 if((colli_map[j] & mask) == 0)
235 double phi = (i % 20) * 18.0 / 180.0 *
F_PI;
240 theta = (j * 3 + 1) * 18.0 / 180.0 *
F_PI;
243 if (i > 19 && i < 40)
245 theta = (j * 3 + 2) * 18.0 / 180.0 *
F_PI;
250 theta = (j * 3 + 3)* 18.0 / 180.0 *
F_PI;
259 lld north_mask = ((
lld)1 << 60);
260 if((colli_map[2] & north_mask) == 0)
266 lld south_mask = ((
lld)1 << 61);
267 if((colli_map[2] & south_mask) == 0)
272 return feasible_eef_directions;
278 std::vector<int> int_map(this->
Divide(), 0);
280 for(
int j = 0; j < 3; j++)
282 for(
int i = 0; i <
divide_; i++)
287 if((colli_map[j] & mask) == 0)
289 int_map[j * divide_ + i] = 1;
295 lld north_mask = ((
lld)1 << 60);
296 if((colli_map[2] & north_mask) == 0)
302 lld south_mask = ((
lld)1 << 61);
303 if((colli_map[2] & south_mask) == 0)
338 for (
int j = 0; j < 3; j++)
340 for (
int i = 0; i <
divide_; i++)
344 theta = (j * 3 + 1) * 18.0 / 180.0 *
F_PI;
347 if (i > 19 && i < 40)
349 theta = (j * 3 + 2) * 18.0 / 180.0 *
F_PI;
354 theta = (j * 3 + 3)* 18.0 / 180.0 *
F_PI;
357 phi = (i % 20) * 18.0 / 180.0 *
F_PI;
378 mask = ((
lld)1 << 61);
385 for (
int i = 0; i < 3; i++)
395 for (
int i = 0; i < exist_edge.size(); i++)
416 if (
Parallel(normal, target_start - target_end))
418 if (
ParallelCase(target_start, target_end, order_start, order_end, normal))
426 if ((target_start - order_end).norm() <
GEO_EPS)
428 if (
SpecialCase(target_start,target_end,order_start,normal ))
435 if ((target_start - order_start).norm() <
GEO_EPS)
437 if (
SpecialCase(target_start, target_end, order_end, normal))
444 if ((target_end - order_end).norm() <
GEO_EPS)
446 if (
SpecialCase(target_end, target_start, order_start, normal))
453 if ((target_end - order_start).norm() <
GEO_EPS)
455 if (
SpecialCase(target_end, target_start, order_end, normal))
463 if (
Case(target_start, target_end, order_start, order_end, normal))
482 if (
DetectCone(target_start, normal, order_start, order_end))
485 if (
DetectCone(target_end, normal, order_start, order_end))
495 #ifdef STRICT_COLLISION 501 #endif // STRICT_COLLISION 504 GenerateVolume(target_start, target_end, order_start, order_end, normal);
505 for (
int i = 0; i <
bulk_.size(); i++)
521 if (
DetectCone(target_s, normal, connect, order_s))
527 #ifdef STRICT_COLLISION 537 for (
int i = 0; i <
bulk_.size(); i++)
551 if ((target_start - order_end).norm() <
GEO_EPS)
553 if (
DetectAngle(target_start, target_end, order_start, normal))
558 if ((target_start - order_start).norm() <
GEO_EPS)
560 if (
DetectAngle(target_start, target_end, order_end, normal))
566 if ((target_end - order_end).norm() <
GEO_EPS)
568 if (
DetectAngle(target_end, target_start, order_start, normal))
574 if ((target_end - order_start).norm() <
GEO_EPS)
576 if (
DetectAngle(target_end, target_start, order_end, normal))
585 if (
DetectCone(target_start, normal, order_start, order_end))
588 if (
DetectCone(target_end, normal, order_start, order_end))
598 #ifdef STRICT_COLLISION 619 std::array<float, 3>
s;
620 s[0] = start.
getX(); s[1] = start.
getY(); s[2] = start.
getZ();
622 s[0] = normal.
getX(); s[1] = normal.
getY(); s[2] = normal.
getZ();
624 start_cone.
ray = start_ray;
626 segment =
Seg(target_start, target_end);
628 auto result = intersection(segment, start_cone);
639 std::array<float, 3>
s;
644 s[0] = cylin_center.
getX(); s[1] = cylin_center.
getY(); s[2] = cylin_center.
getZ();
646 s[0] = normal.
getX(); s[1] = normal.
getY(); s[2] = normal.
getZ();
649 cylinder.
axis = cylinder_line;
655 segment =
Seg(target_start, target_end);
657 auto fiq_result = fiq(segment, cylinder);
659 return fiq_result.intersect;
669 auto fiq_result = fiq(segment, triangle_);
670 return fiq_result.intersect;
678 std::array<float, 3>
s;
681 s[0] = cylin_center.
getX(); s[1] = cylin_center.
getY(); s[2] = cylin_center.
getZ();
683 s[0] = normal.
getX(); s[1] = normal.
getY(); s[2] = normal.
getZ();
685 cylinder.
axis = cylinder_line;
692 segment =
Seg(target_start, target_end);
694 auto fiq_result = fiq(segment, cylinder);
696 return fiq_result.intersect;
704 double edge_length = t.
norm();
727 #ifdef STRICT_COLLISION 731 vector<GeoV3> start_circle_point,end_circle_point;
732 for (
int i = 0; i < 16; i++)
734 double part = 2 *
F_PI / 16;
735 double theta = i*part;
737 end_circle_point.push_back(start_circle_point[i] + end - start);
740 for (
int i = 0; i < 15; i++)
742 bulk_.push_back(
Triangle(start_circle_point[i], start_circle_point[i + 1], end_circle_point[i]));
743 bulk_.push_back(
Triangle(end_circle_point[i], end_circle_point[i + 1], start_circle_point[i + 1]));
745 bulk_.push_back(
Triangle(start_circle_point[15], start_circle_point[0], end_circle_point[15]));
746 bulk_.push_back(
Triangle(end_circle_point[15], end_circle_point[0], start_circle_point[0]));
748 for (
int i = 0; i < 15; i++)
750 bulk_.push_back(
Triangle(start_circle_point[i], start_circle_point[i + 1], end_circle_point[i]));
751 bulk_.push_back(
Triangle(end_circle_point[i], end_circle_point[i + 1], start_circle_point[i + 1]));
753 bulk_.push_back(
Triangle(start_circle_point[15], start_circle_point[0], end_circle_point[15]));
754 bulk_.push_back(
Triangle(end_circle_point[15], end_circle_point[0], start_circle_point[0]));
770 bulk_.push_back(
Triangle(start_top_front_up, start_top_front_down, end_top_front_down));
771 bulk_.push_back(
Triangle(start_top_front_up, end_top_front_up, end_top_front_down));
772 bulk_.push_back(
Triangle(start_top_back_up, start_top_back_down, end_top_back_down));
773 bulk_.push_back(
Triangle(start_top_back_up, end_top_back_up, end_top_back_down));
778 bulk_.push_back(
Triangle(end, end_front_cone, start_front_cone));
779 bulk_.push_back(
Triangle(start_front_cone, end_front_cone, start_front_cylinder));
780 bulk_.push_back(
Triangle(end_front_cone, end_front_cylinder, start_front_cylinder));
784 bulk_.push_back(
Triangle(start, start_back_cone, end_back_cone));
785 bulk_.push_back(
Triangle(start_back_cone, end_back_cylinder, end_back_cone));
786 bulk_.push_back(
Triangle(start_back_cone, start_back_cylinder, end_back_cylinder));
791 GeoV3 t = target_s - connect;
792 double edge_length = t.
norm();
813 bulk_.push_back(
Triangle(start, start_back_cone, start_front_cone));
814 bulk_.push_back(
Triangle(start_front_cylinder, start_back_cone, start_front_cone));
815 bulk_.push_back(
Triangle(start_front_cylinder, start_back_cylinder, start_back_cone));
817 #ifdef STRICT_COLLISION 824 vector<GeoV3> start_circle_point, end_circle_point;
825 for (
int i = 0; i < 16; i++)
827 double part = 2 *
F_PI / 16;
828 double theta = i*part;
830 end_circle_point.push_back(start_circle_point[i] + end - start);
833 for (
int i = 0; i < 15; i++)
835 bulk_.push_back(
Triangle(start_circle_point[i], start_circle_point[i + 1], end_circle_point[i]));
836 bulk_.push_back(
Triangle(end_circle_point[i], end_circle_point[i + 1], start_circle_point[i + 1]));
838 bulk_.push_back(
Triangle(start_circle_point[15], start_circle_point[0], end_circle_point[15]));
839 bulk_.push_back(
Triangle(end_circle_point[15], end_circle_point[0], start_circle_point[0]));
854 bulk_.push_back(
Triangle(start_top_front_up, start_top_front_down, end_top_front_down));
855 bulk_.push_back(
Triangle(start_top_front_up, end_top_front_up, end_top_front_down));
856 bulk_.push_back(
Triangle(start_top_back_up, start_top_back_down, end_top_back_down));
857 bulk_.push_back(
Triangle(start_top_back_up, end_top_back_up, end_top_back_down));
874 auto dcpq_result = dcpq(segment, segment_target);
875 return dcpq_result.distance;
881 segment.
p[0][0] = target_start.
x();
882 segment.
p[0][1] = target_start.
y();
883 segment.
p[0][2] = target_start.
z();
884 segment.
p[1][0] = target_end.
x();
885 segment.
p[1][1] = target_end.
y();
886 segment.
p[1][2] = target_end.
z();
893 segment.
p[0][0] = target_start.
getX();
894 segment.
p[0][1] = target_start.
getY();
895 segment.
p[0][2] = target_start.
getZ();
896 segment.
p[1][0] = target_end.
getX();
897 segment.
p[1][1] = target_end.
getY();
898 segment.
p[1][2] = target_end.
getZ();
905 triangle.
v[0][0] = a.
getX();
906 triangle.
v[0][1] = a.
getY();
907 triangle.
v[0][2] = a.
getZ();
908 triangle.
v[1][0] = b.
getX();
909 triangle.
v[1][1] = b.
getY();
910 triangle.
v[1][2] = b.
getZ();
911 triangle.
v[2][0] = c.
getX();
912 triangle.
v[2][1] = c.
getY();
913 triangle.
v[2][2] = c.
getZ();
static const double MAX_COLLISION_CHECK_DIST
bool Case(GeoV3 target_start, GeoV3 target_end, GeoV3 order_start, GeoV3 order_end, GeoV3 normal)
int ColFreeAngle(const std::vector< lld > &colli_map)
bool DetectBulk(WF_edge *order_e, double theta, double phi)
Vector< N, Real > direction
std::vector< int > ConvertCollisionMapToIntMap(const std::vector< lld > &colli_map)
bool DetectEdges(std::vector< WF_edge * > exist_edge, double theta, double phi)
bool SpecialCase(GeoV3 connect, GeoV3 target_s, GeoV3 order_s, GeoV3 normal)
void ModifyAngle(std::vector< lld > &angle_state, const std::vector< lld > &colli_map)
bool DetectAngle(GeoV3 connect, GeoV3 end, GeoV3 target_end, GeoV3 normal)
bool DetectEdge(WF_edge *order_e, vector< lld > &colli_map)
Eigen::Vector3d ConvertAngleToEigenDirection(double theta, double phi)
bool DetectTriangle(Triangle triangle, GeoV3 target_start, GeoV3 target_end)
TFSIMD_FORCE_INLINE Vector3 cross(const Vector3 &v) const
static double angle(Vector3d vec1, Vector3d vec2)
std::array< Vector< N, Real >, 2 > p
GeoV3 Orientation(double theta, double phi)
bool ParallelCase(GeoV3 target_start, GeoV3 target_end, GeoV3 order_start, GeoV3 order_end, GeoV3 normal)
bool DetectCylinder(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end)
std::vector< Eigen::Vector3d > ConvertCollisionMapToEigenDirections(const std::vector< lld > &colli_map)
std::vector< Triangle > bulk_
Vector< N, Real > direction
GLboolean GLboolean GLboolean GLboolean a
bool Parallel(GeoV3 a, GeoV3 b)
bool DetectCollision(WF_edge *target_e, DualGraph *ptr_subgraph, std::vector< lld > &result_map)
gte::Segment< 3, float > Seg(point target_start, point target_end)
bool DetectTopCylinder(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end)
std::vector< std::vector< lld > * > colli_map_
GLboolean GLboolean GLboolean b
static trimesh::Vec< D, T > abs(const trimesh::Vec< D, T > &v)
bool DetectCone(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end)
bool isExistingEdge(WF_edge *e)
gte::Triangle< 3, float > Tri(GeoV3 a, GeoV3 b, GeoV3 c)
GLdouble GLdouble GLdouble GLdouble q
void Init(vector< lld > &colli_map)
double Distance(WF_edge *order_e)
void GenerateVolume(GeoV3 start, GeoV3 end, GeoV3 target_start, GeoV3 target_end, GeoV3 normal)
std::array< Vector< N, Real >, 3 > v
int SizeOfEdgeList() const