GteIntrOrientedBox3Cylinder3.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.4.0 (2016/11/08)
7 
8 #pragma once
9 
12 
13 // The query considers the cylinder and box to be solids.
14 
15 namespace gte
16 {
17 
18 template <typename Real>
19 class TIQuery<Real, OrientedBox3<Real>, Cylinder3<Real>>
20 {
21 public:
22  struct Result
23  {
24  bool intersect;
25  };
26 
27  Result operator()(OrientedBox3<Real> const& box, Cylinder3<Real> const& cylinder);
28 };
29 
30 
31 template <typename Real>
34  OrientedBox3<Real> const& box, Cylinder3<Real> const& cylinder)
35 {
36  // Transform the box and cylinder so that the box is axis-aligned.
37  AlignedBox3<Real> aabb(-box.extent, box.extent);
38  Vector3<Real> diff = cylinder.axis.origin - box.center;
39  Cylinder3<Real> transformedCylinder;
40  transformedCylinder.radius = cylinder.radius;
41  transformedCylinder.height = cylinder.height;
42  for (int i = 0; i < 3; ++i)
43  {
44  transformedCylinder.axis.origin[i] = Dot(box.axis[i], diff);
45  transformedCylinder.axis.direction[i] = Dot(box.axis[i], cylinder.axis.direction);
46  }
47 
49  auto aabbCylinderResult = aabbCylinderQuery(aabb, transformedCylinder);
50  Result result;
51  result.intersect = aabbCylinderResult.intersect;
52  return result;
53 }
54 
55 }
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
Line3< Real > axis
Definition: GteCylinder3.h:31


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