FCL  0.6.0
Flexible Collision Library
collision_geometry-inl.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_COLLISION_GEOMETRY_INL_H
39 #define FCL_COLLISION_GEOMETRY_INL_H
40 
41 #include "fcl/geometry/collision_geometry.h"
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 class CollisionGeometry<double>;
49 
50 //==============================================================================
51 template <typename S>
52 CollisionGeometry<S>::CollisionGeometry()
53  : aabb_center(Vector3<S>::Zero()),
54  aabb_radius((S)0),
55  user_data(nullptr),
56  cost_density((S)1),
57  threshold_occupied((S)1),
58  threshold_free((S)0)
59 {
60  // Do nothing
61 }
62 
63 //==============================================================================
64 template <typename S>
65 CollisionGeometry<S>::~CollisionGeometry()
66 {
67  // Do nothing
68 }
69 
70 //==============================================================================
71 template <typename S>
73 {
74  return OT_UNKNOWN;
75 }
76 
77 //==============================================================================
78 template <typename S>
80 {
81  return BV_UNKNOWN;
82 }
83 
84 //==============================================================================
85 template <typename S>
87 {
88  return user_data;
89 }
90 
91 //==============================================================================
92 template <typename S>
94 {
95  user_data = data;
96 }
97 
98 //==============================================================================
99 template <typename S>
101 {
102  return cost_density >= threshold_occupied;
103 }
104 
105 //==============================================================================
106 template <typename S>
108 {
109  return cost_density <= threshold_free;
110 }
111 
112 //==============================================================================
113 template <typename S>
115 {
116  return !isOccupied() && !isFree();
117 }
118 
119 //==============================================================================
120 template <typename S>
122 {
123  return Vector3<S>::Zero();
124 }
125 
126 //==============================================================================
127 template <typename S>
129 {
130  return Matrix3<S>::Zero();
131 }
132 
133 //==============================================================================
134 template <typename S>
136 {
137  return 0;
138 }
139 
140 //==============================================================================
141 template <typename S>
143 {
144  Matrix3<S> C = computeMomentofInertia();
145  Vector3<S> com = computeCOM();
146  S V = computeVolume();
147 
148  Matrix3<S> m;
149  m << C(0, 0) - V * (com[1] * com[1] + com[2] * com[2]),
150  C(0, 1) + V * com[0] * com[1],
151  C(0, 2) + V * com[0] * com[2],
152  C(1, 0) + V * com[1] * com[0],
153  C(1, 1) - V * (com[0] * com[0] + com[2] * com[2]),
154  C(1, 2) + V * com[1] * com[2],
155  C(2, 0) + V * com[2] * com[0],
156  C(2, 1) + V * com[2] * com[1],
157  C(2, 2) - V * (com[0] * com[0] + com[1] * com[1]);
158 
159  return m;
160 }
161 
162 } // namespace fcl
163 
164 #endif
virtual Vector3< S > computeCOM() const
compute center of mass
Definition: collision_geometry-inl.h:121
virtual OBJECT_TYPE getObjectType() const
get the type of the object
Definition: collision_geometry-inl.h:72
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18, kDOP24), basic shape (box, sphere, ellipsoid, capsule, cone, cylinder, convex, plane, halfspace, triangle), and octree
Definition: collision_geometry.h:54
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
virtual Matrix3< S > computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: collision_geometry-inl.h:128
void * getUserData() const
get user data in geometry
Definition: collision_geometry-inl.h:86
bool isFree() const
whether the object is completely free
Definition: collision_geometry-inl.h:107
bool isUncertain() const
whether the object has some uncertainty
Definition: collision_geometry-inl.h:114
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_geometry.h:51
void setUserData(void *data)
set user data in geometry
Definition: collision_geometry-inl.h:93
virtual S computeVolume() const
compute the volume
Definition: collision_geometry-inl.h:135
virtual NODE_TYPE getNodeType() const
get the node type
Definition: collision_geometry-inl.h:79
bool isOccupied() const
whether the object is completely occupied
Definition: collision_geometry-inl.h:100
virtual Matrix3< S > computeMomentofInertiaRelatedToCOM() const
compute the inertia matrix, related to the com
Definition: collision_geometry-inl.h:142