FCL  0.6.0
Flexible Collision Library
box_box.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_DETAIL_BOXBOX_H
39 #define FCL_NARROWPHASE_DETAIL_BOXBOX_H
40 
41 #include "fcl/common/types.h"
42 #include "fcl/narrowphase/contact_point.h"
43 #include "fcl/geometry/shape/box.h"
44 
45 namespace fcl
46 {
47 
48 namespace detail
49 {
50 
51 template <typename S>
52 void lineClosestApproach(const Vector3<S>& pa, const Vector3<S>& ua,
53  const Vector3<S>& pb, const Vector3<S>& ub,
54  S* alpha, S* beta);
55 
56 // find all the intersection points between the 2D rectangle with vertices
57 // at (+/-h[0],+/-h[1]) and the 2D quadrilateral with vertices (p[0],p[1]),
58 // (p[2],p[3]),(p[4],p[5]),(p[6],p[7]).
59 //
60 // the intersection points are returned as x,y pairs in the 'ret' array.
61 // the number of intersection points is returned by the function (this will
62 // be in the range 0 to 8).
63 template <typename S>
64 int intersectRectQuad2(S h[2], S p[8], S ret[16]);
65 
66 // given n points in the plane (array p, of size 2*n), generate m points that
67 // best represent the whole set. the definition of 'best' here is not
68 // predetermined - the idea is to select points that give good box-box
69 // collision detection behavior. the chosen point indexes are returned in the
70 // array iret (of size m). 'i0' is always the first entry in the array.
71 // n must be in the range [1..8]. m must be in the range [1..n]. i0 must be
72 // in the range [0..n-1].
73 template <typename S>
74 void cullPoints2(int n, S p[], int m, int i0, int iret[]);
75 
76 template <typename S, typename DerivedA, typename DerivedB>
77 int boxBox2(
78  const Vector3<S>& side1,
79  const Eigen::MatrixBase<DerivedA>& R1,
80  const Eigen::MatrixBase<DerivedB>& T1,
81  const Vector3<S>& side2,
82  const Eigen::MatrixBase<DerivedA>& R2,
83  const Eigen::MatrixBase<DerivedB>& T2,
84  Vector3<S>& normal,
85  S* depth,
86  int* return_code,
87  int maxc,
88  std::vector<ContactPoint<S>>& contacts);
89 
90 template <typename S>
91 int boxBox2(
92  const Vector3<S>& side1,
93  const Transform3<S>& tf1,
94  const Vector3<S>& side2,
95  const Transform3<S>& tf2,
96  Vector3<S>& normal,
97  S* depth,
98  int* return_code,
99  int maxc,
100  std::vector<ContactPoint<S>>& contacts);
101 
102 template <typename S>
103 bool boxBoxIntersect(const Box<S>& s1, const Transform3<S>& tf1,
104  const Box<S>& s2, const Transform3<S>& tf2,
105  std::vector<ContactPoint<S>>* contacts_);
106 
107 } // namespace detail
108 } // namespace fcl
109 
110 #include "fcl/narrowphase/detail/primitive_shape_algorithm/box_box-inl.h"
111 
112 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45