GteIntrHalfspace3Capsule3.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 
10 #include <Mathematics/GteCapsule.h>
12 #include <Mathematics/GteFIQuery.h>
13 #include <Mathematics/GteTIQuery.h>
14 
15 // Queries for intersection of objects with halfspaces. These are useful for
16 // containment testing, object culling, and clipping.
17 
18 namespace gte
19 {
20 
21 template <typename Real>
22 class TIQuery<Real, Halfspace3<Real>, Capsule3<Real>>
23 {
24 public:
25  struct Result
26  {
27  bool intersect;
28  };
29 
30  Result operator()(Halfspace3<Real> const& halfspace,
31  Capsule3<Real> const& capsule);
32 };
33 
34 
35 template <typename Real>
38  Halfspace3<Real> const& halfspace, Capsule3<Real> const& capsule)
39 {
40  Result result;
41 
42  // Project the capsule onto the normal line. The plane of the halfspace
43  // occurs at the origin (zero) of the normal line.
44  Real e0 =
45  Dot(halfspace.normal, capsule.segment.p[0]) - halfspace.constant;
46  Real e1 =
47  Dot(halfspace.normal, capsule.segment.p[1]) - halfspace.constant;
48 
49  // The capsule and halfspace intersect when the projection interval
50  // maximum is nonnegative.
51  result.intersect = (std::max(e0, e1) + capsule.radius >= (Real)0);
52  return result;
53 }
54 
55 
56 }
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
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