GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/distance/capsule_halfspace.cpp Lines: 11 23 47.8 %
Date: 2024-02-09 12:57:42 Branches: 0 2 0.0 %

Line Branch Exec Source
1
/*
2
 * Software License Agreement (BSD License)
3
 *
4
 *  Copyright (c) 2011-2014, Willow Garage, Inc.
5
 *  Copyright (c) 2014-2015, Open Source Robotics Foundation
6
 *  Copyright (c) 2018-2019, Center National de la Recherche Scientifique
7
 *  All rights reserved.
8
 *
9
 *  Redistribution and use in source and binary forms, with or without
10
 *  modification, are permitted provided that the following conditions
11
 *  are met:
12
 *
13
 *   * Redistributions of source code must retain the above copyright
14
 *     notice, this list of conditions and the following disclaimer.
15
 *   * Redistributions in binary form must reproduce the above
16
 *     copyright notice, this list of conditions and the following
17
 *     disclaimer in the documentation and/or other materials provided
18
 *     with the distribution.
19
 *   * Neither the name of Open Source Robotics Foundation nor the names of its
20
 *     contributors may be used to endorse or promote products derived
21
 *     from this software without specific prior written permission.
22
 *
23
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
 *  POSSIBILITY OF SUCH DAMAGE.
35
 */
36
37
/** \author Florent Lamiraux */
38
39
#include <cmath>
40
#include <limits>
41
#include <hpp/fcl/math/transform.h>
42
#include <hpp/fcl/shape/geometric_shapes.h>
43
44
#include <hpp/fcl/internal/shape_shape_func.h>
45
#include "../narrowphase/details.h"
46
47
namespace hpp {
48
namespace fcl {
49
struct GJKSolver;
50
51
template <>
52
60
FCL_REAL ShapeShapeDistance<Capsule, Halfspace>(
53
    const CollisionGeometry* o1, const Transform3f& tf1,
54
    const CollisionGeometry* o2, const Transform3f& tf2, const GJKSolver*,
55
    const DistanceRequest&, DistanceResult& result) {
56
60
  const Capsule& s1 = static_cast<const Capsule&>(*o1);
57
60
  const Halfspace& s2 = static_cast<const Halfspace&>(*o2);
58
60
  details::capsuleHalfspaceIntersect(s1, tf1, s2, tf2, result.min_distance,
59
60
                                     result.nearest_points[0],
60
60
                                     result.nearest_points[1], result.normal);
61
60
  result.o1 = o1;
62
60
  result.o2 = o2;
63
60
  result.b1 = -1;
64
60
  result.b2 = -1;
65
60
  return result.min_distance;
66
}
67
68
template <>
69
FCL_REAL ShapeShapeDistance<Halfspace, Capsule>(
70
    const CollisionGeometry* o1, const Transform3f& tf1,
71
    const CollisionGeometry* o2, const Transform3f& tf2, const GJKSolver*,
72
    const DistanceRequest&, DistanceResult& result) {
73
  const Halfspace& s1 = static_cast<const Halfspace&>(*o1);
74
  const Capsule& s2 = static_cast<const Capsule&>(*o2);
75
  details::capsuleHalfspaceIntersect(s2, tf2, s1, tf1, result.min_distance,
76
                                     result.nearest_points[1],
77
                                     result.nearest_points[0], result.normal);
78
  result.o1 = o1;
79
  result.o2 = o2;
80
  result.b1 = -1;
81
  result.b2 = -1;
82
  result.normal = -result.normal;
83
  return result.min_distance;
84
}
85
}  // namespace fcl
86
87
}  // namespace hpp