123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #pragma once
- #include <Mathematics/ExtremalQuery3.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class ExtremalQuery3PRJ : public ExtremalQuery3<Real>
- {
- public:
-
- ExtremalQuery3PRJ(Polyhedron3<Real> const& polytope)
- :
- ExtremalQuery3<Real>(polytope)
- {
- mCentroid = this->mPolytope.ComputeVertexAverage();
- }
-
- ExtremalQuery3PRJ(ExtremalQuery3PRJ const&) = delete;
- ExtremalQuery3PRJ& operator=(ExtremalQuery3PRJ const&) = delete;
-
-
- virtual void GetExtremeVertices(Vector3<Real> const& direction,
- int& positiveDirection, int& negativeDirection) override
- {
- Real minValue = std::numeric_limits<Real>::max(), maxValue = -minValue;
- negativeDirection = -1;
- positiveDirection = -1;
- auto vertexPool = this->mPolytope.GetVertexPool();
- for (auto i : this->mPolytope.GetUniqueIndices())
- {
- Vector3<Real> diff = vertexPool.get()->at(i) - mCentroid;
- Real dot = Dot(direction, diff);
- if (dot < minValue)
- {
- negativeDirection = i;
- minValue = dot;
- }
- if (dot > maxValue)
- {
- positiveDirection = i;
- maxValue = dot;
- }
- }
- }
- private:
- Vector3<Real> mCentroid;
- };
- }
|