GteExtremalQuery3PRJ.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 <limits>
12 
13 namespace gte
14 {
15 
16 template <typename Real>
17 class ExtremalQuery3PRJ : public ExtremalQuery3<Real>
18 {
19 public:
20  // Construction.
21  ExtremalQuery3PRJ(Polyhedron3<Real> const& polytope);
22 
23  // Disallow copying and assignment.
24  ExtremalQuery3PRJ(ExtremalQuery3PRJ const&) = delete;
26 
27  // Compute the extreme vertices in the specified direction and return the
28  // indices of the vertices in the polyhedron vertex array.
29  virtual void GetExtremeVertices(Vector3<Real> const& direction,
30  int& positiveDirection, int& negativeDirection) override;
31 
32 private:
34 };
35 
36 
37 template <typename Real>
39  :
40  ExtremalQuery3<Real>(polytope)
41 {
42  mCentroid = this->mPolytope.ComputeVertexAverage();
43 }
44 
45 template <typename Real>
47  int& positiveDirection, int& negativeDirection)
48 {
49  Real minValue = std::numeric_limits<Real>::max(), maxValue = -minValue;
50  negativeDirection = -1;
51  positiveDirection = -1;
52 
53  auto vertexPool = this->mPolytope.GetVertexPool();
54  for (auto i : this->mPolytope.GetUniqueIndices())
55  {
56  Vector3<Real> diff = vertexPool.get()->at(i) - mCentroid;
57  Real dot = Dot(direction, diff);
58  if (dot < minValue)
59  {
60  negativeDirection = i;
61  minValue = dot;
62  }
63  if (dot > maxValue)
64  {
65  positiveDirection = i;
66  maxValue = dot;
67  }
68  }
69 }
70 
71 }
ExtremalQuery3PRJ(Polyhedron3< Real > const &polytope)
virtual void GetExtremeVertices(Vector3< Real > const &direction, int &positiveDirection, int &negativeDirection) override
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Polyhedron3< Real > const & mPolytope
ExtremalQuery3PRJ & operator=(ExtremalQuery3PRJ const &)=delete


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59