GteIntrPlane3Capsule3.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 #include <Mathematics/GteCapsule.h>
12 #include <Mathematics/GteTIQuery.h>
13 
14 namespace gte
15 {
16 
17 template <typename Real>
18 class TIQuery<Real, Plane3<Real>, Capsule3<Real>>
19 {
20 public:
21  struct Result
22  {
23  bool intersect;
24  };
25 
26  Result operator()(Plane3<Real> const& plane,
27  Capsule3<Real> const& capsule);
28 };
29 
30 
31 template <typename Real>
34  Plane3<Real> const& plane, Capsule3<Real> const& capsule)
35 {
36  Result result;
37 
39  Real sdistance0 = vpQuery(capsule.segment.p[0], plane).signedDistance;
40  Real sdistance1 = vpQuery(capsule.segment.p[1], plane).signedDistance;
41  if (sdistance0 * sdistance1 <= (Real)0)
42  {
43  // A capsule segment endpoint is on the plane or the two endpoints
44  // are on opposite sides of the plane.
45  result.intersect = true;
46  return result;
47  }
48 
49  // The endpoints on same side of plane, but the endpoint spheres might
50  // intersect the plane.
51  result.intersect =
52  std::abs(sdistance0) <= capsule.radius ||
53  std::abs(sdistance1) <= capsule.radius;
54  return result;
55 }
56 
57 
58 }
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
Definition: GteBSNumber.h:966
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
GLuint64EXT * result
Definition: glext.h:10003


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00