FCL  0.6.0
Flexible Collision Library
gjk_solver_libccd.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
38 #ifndef FCL_NARROWPHASE_GJKSOLVERLIBCCD_H
39 #define FCL_NARROWPHASE_GJKSOLVERLIBCCD_H
40 
41 #include "fcl/common/deprecated.h"
42 #include "fcl/common/types.h"
43 #include "fcl/narrowphase/contact_point.h"
44 
45 namespace fcl
46 {
47 
48 namespace detail
49 {
50 
52 template <typename S_>
54 {
55  using S = S_;
56 
59  template<typename Shape1, typename Shape2>
60  FCL_DEPRECATED
61  bool shapeIntersect(
62  const Shape1& s1,
63  const Transform3<S>& tf1,
64  const Shape2& s2,
65  const Transform3<S>& tf2,
66  Vector3<S>* contact_points,
67  S* penetration_depth,
68  Vector3<S>* normal) const;
69 
71  template<typename Shape1, typename Shape2>
72  bool shapeIntersect(
73  const Shape1& s1,
74  const Transform3<S>& tf1,
75  const Shape2& s2,
76  const Transform3<S>& tf2,
77  std::vector<ContactPoint<S>>* contacts = nullptr) const;
78 
80  template<typename Shape>
82  const Shape& s,
83  const Transform3<S>& tf,
84  const Vector3<S>& P1,
85  const Vector3<S>& P2,
86  const Vector3<S>& P3,
87  Vector3<S>* contact_points = nullptr,
88  S* penetration_depth = nullptr,
89  Vector3<S>* normal = nullptr) const;
90 
92  template<typename Shape>
94  const Shape& s,
95  const Transform3<S>& tf1,
96  const Vector3<S>& P1,
97  const Vector3<S>& P2,
98  const Vector3<S>& P3,
99  const Transform3<S>& tf2,
100  Vector3<S>* contact_points = nullptr,
101  S* penetration_depth = nullptr,
102  Vector3<S>* normal = nullptr) const;
103 
105  template<typename Shape1, typename Shape2>
106  bool shapeDistance(
107  const Shape1& s1,
108  const Transform3<S>& tf1,
109  const Shape2& s2,
110  const Transform3<S>& tf2,
111  S* dist = nullptr,
112  Vector3<S>* p1 = nullptr,
113  Vector3<S>* p2 = nullptr) const;
114 
116  template<typename Shape>
118  const Shape& s,
119  const Transform3<S>& tf,
120  const Vector3<S>& P1,
121  const Vector3<S>& P2,
122  const Vector3<S>& P3,
123  S* dist = nullptr,
124  Vector3<S>* p1 = nullptr,
125  Vector3<S>* p2 = nullptr) const;
126 
128  template<typename Shape>
130  const Shape& s,
131  const Transform3<S>& tf1,
132  const Vector3<S>& P1,
133  const Vector3<S>& P2,
134  const Vector3<S>& P3,
135  const Transform3<S>& tf2,
136  S* dist = nullptr,
137  Vector3<S>* p1 = nullptr,
138  Vector3<S>* p2 = nullptr) const;
139 
142 
143  void enableCachedGuess(bool if_enable) const;
144 
145  void setCachedGuess(const Vector3<S>& guess) const;
146 
147  Vector3<S> getCachedGuess() const;
148 
151 
154 
157 
160 
161 };
162 
165 
166 } // namespace detail
167 } // namespace fcl
168 
169 #include "fcl/narrowphase/detail/gjk_solver_libccd-inl.h"
170 
171 #endif
bool shapeTriangleDistance(const Shape &s, const Transform3< S > &tf, const Vector3< S > &P1, const Vector3< S > &P2, const Vector3< S > &P3, S *dist=nullptr, Vector3< S > *p1=nullptr, Vector3< S > *p2=nullptr) const
distance computation between one shape and a triangle
Definition: gjk_solver_libccd-inl.h:719
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
unsigned int max_collision_iterations
maximum number of iterations used in GJK algorithm for collision
Definition: gjk_solver_libccd.h:150
Minimal contact information returned by collision.
Definition: contact_point.h:48
FCL_DEPRECATED bool shapeIntersect(const Shape1 &s1, const Transform3< S > &tf1, const Shape2 &s2, const Transform3< S > &tf2, Vector3< S > *contact_points, S *penetration_depth, Vector3< S > *normal) const
intersection checking between two shapes
S collision_tolerance
the threshold used in GJK algorithm to stop collision iteration
Definition: gjk_solver_libccd.h:156
bool shapeTriangleIntersect(const Shape &s, const Transform3< S > &tf, const Vector3< S > &P1, const Vector3< S > &P2, const Vector3< S > &P3, Vector3< S > *contact_points=nullptr, S *penetration_depth=nullptr, Vector3< S > *normal=nullptr) const
intersection checking between one shape and a triangle
Definition: gjk_solver_libccd-inl.h:369
collision and distance solver based on libccd library.
Definition: gjk_solver_libccd.h:53
S distance_tolerance
the threshold used in GJK algorithm to stop distance iteration
Definition: gjk_solver_libccd.h:159
bool shapeDistance(const Shape1 &s1, const Transform3< S > &tf1, const Shape2 &s2, const Transform3< S > &tf2, S *dist=nullptr, Vector3< S > *p1=nullptr, Vector3< S > *p2=nullptr) const
distance computation between two shapes
Definition: gjk_solver_libccd-inl.h:569
GJKSolver_libccd()
default setting for GJK algorithm
Definition: gjk_solver_libccd-inl.h:834
unsigned int max_distance_iterations
maximum number of iterations used in GJK algorithm for distance
Definition: gjk_solver_libccd.h:153