123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #pragma once
- #include <Mathematics/IntrSegment2AlignedBox2.h>
- #include <Mathematics/OrientedBox.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class TIQuery<Real, Segment2<Real>, OrientedBox2<Real>>
- :
- public TIQuery<Real, Segment2<Real>, AlignedBox2<Real>>
- {
- public:
- struct Result
- :
- public TIQuery<Real, Segment2<Real>, AlignedBox2<Real>>::Result
- {
-
- };
- Result operator()(Segment2<Real> const& segment, OrientedBox2<Real> const& box)
- {
-
- Vector2<Real> tmpOrigin, tmpDirection;
- Real segExtent;
- segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
- Vector2<Real> diff = tmpOrigin - box.center;
- Vector2<Real> segOrigin
- {
- Dot(diff, box.axis[0]),
- Dot(diff, box.axis[1])
- };
- Vector2<Real> segDirection
- {
- Dot(tmpDirection, box.axis[0]),
- Dot(tmpDirection, box.axis[1])
- };
- Result result;
- this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
- return result;
- }
- };
- template <typename Real>
- class FIQuery<Real, Segment2<Real>, OrientedBox2<Real>>
- :
- public FIQuery<Real, Segment2<Real>, AlignedBox2<Real>>
- {
- public:
- struct Result
- :
- public FIQuery<Real, Segment2<Real>, AlignedBox2<Real>>::Result
- {
-
-
-
-
-
- std::array<Real, 2> cdeParameter;
- };
- Result operator()(Segment2<Real> const& segment, OrientedBox2<Real> const& box)
- {
-
- Vector2<Real> tmpOrigin, tmpDirection;
- Real segExtent;
- segment.GetCenteredForm(tmpOrigin, tmpDirection, segExtent);
- Vector2<Real> diff = tmpOrigin - box.center;
- Vector2<Real> segOrigin
- {
- Dot(diff, box.axis[0]),
- Dot(diff, box.axis[1])
- };
- Vector2<Real> segDirection
- {
- Dot(tmpDirection, box.axis[0]),
- Dot(tmpDirection, box.axis[1])
- };
- Result result;
- this->DoQuery(segOrigin, segDirection, segExtent, box.extent, result);
- for (int i = 0; i < result.numIntersections; ++i)
- {
- // Compute the segment in the aligned-box coordinate system
- // and then translate it back to the original coordinates
- // using the box cener.
- result.point[i] = box.center + (segOrigin + result.parameter[i] * segDirection);
- result.cdeParameter[i] = result.parameter[i];
-
-
- result.parameter[i] = (result.parameter[i] / segExtent + (Real)1) * (Real)0.5;
- }
- return result;
- }
- };
- }
|