Wm4Query2Filtered.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 namespace Wm4
00018 {
00019
00020 template <class Real>
00021 Query2Filtered<Real>::Query2Filtered (int iVQuantity,
00022 const Vector2<Real>* akVertex, Real fUncertainty)
00023 :
00024 Query2<Real>(iVQuantity,akVertex),
00025 m_kRQuery(iVQuantity,akVertex)
00026 {
00027 assert((Real)0.0 <= fUncertainty && fUncertainty <= (Real)1.0);
00028 m_fUncertainty = fUncertainty;
00029 }
00030
00031 template <class Real>
00032 Query2Filtered<Real>::~Query2Filtered ()
00033 {
00034 }
00035
00036 template <class Real>
00037 Query::Type Query2Filtered<Real>::GetType () const
00038 {
00039 return Query::QT_FILTERED;
00040 }
00041
00042 template <class Real>
00043 int Query2Filtered<Real>::ToLine (const Vector2<Real>& rkP, int iV0, int iV1)
00044 const
00045 {
00046 const Vector2<Real>& rkV0 = m_akVertex[iV0];
00047 const Vector2<Real>& rkV1 = m_akVertex[iV1];
00048
00049 Real fX0 = rkP[0] - rkV0[0];
00050 Real fY0 = rkP[1] - rkV0[1];
00051 Real fX1 = rkV1[0] - rkV0[0];
00052 Real fY1 = rkV1[1] - rkV0[1];
00053
00054 Real fLen0 = Math<Real>::Sqrt(fX0*fX0 + fY0*fY0);
00055 Real fLen1 = Math<Real>::Sqrt(fX1*fX1 + fY1*fY1);
00056 Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1;
00057
00058 Real fDet2 = Det2(fX0,fY0,fX1,fY1);
00059 if (Math<Real>::FAbs(fDet2) >= fScaledUncertainty)
00060 {
00061 return (fDet2 > (Real)0.0 ? +1 : (fDet2 < (Real)0.0 ? -1 : 0));
00062 }
00063
00064 return m_kRQuery.ToLine(rkP,iV0,iV1);
00065 }
00066
00067 template <class Real>
00068 int Query2Filtered<Real>::ToCircumcircle (const Vector2<Real>& rkP, int iV0,
00069 int iV1, int iV2) const
00070 {
00071 const Vector2<Real>& rkV0 = m_akVertex[iV0];
00072 const Vector2<Real>& rkV1 = m_akVertex[iV1];
00073 const Vector2<Real>& rkV2 = m_akVertex[iV2];
00074
00075 Real fS0x = rkV0[0] + rkP[0];
00076 Real fD0x = rkV0[0] - rkP[0];
00077 Real fS0y = rkV0[1] + rkP[1];
00078 Real fD0y = rkV0[1] - rkP[1];
00079 Real fS1x = rkV1[0] + rkP[0];
00080 Real fD1x = rkV1[0] - rkP[0];
00081 Real fS1y = rkV1[1] + rkP[1];
00082 Real fD1y = rkV1[1] - rkP[1];
00083 Real fS2x = rkV2[0] + rkP[0];
00084 Real fD2x = rkV2[0] - rkP[0];
00085 Real fS2y = rkV2[1] + rkP[1];
00086 Real fD2y = rkV2[1] - rkP[1];
00087 Real fZ0 = fS0x*fD0x + fS0y*fD0y;
00088 Real fZ1 = fS1x*fD1x + fS1y*fD1y;
00089 Real fZ2 = fS2x*fD2x + fS2y*fD2y;
00090
00091 Real fLen0 = Math<Real>::Sqrt(fD0x*fD0x + fD0y*fD0y + fZ0*fZ0);
00092 Real fLen1 = Math<Real>::Sqrt(fD1x*fD1x + fD1y*fD1y + fZ1*fZ1);
00093 Real fLen2 = Math<Real>::Sqrt(fD2x*fD2x + fD2y*fD2y + fZ2*fZ2);
00094 Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2;
00095
00096 Real fDet3 = Det3(fD0x,fD0y,fZ0,fD1x,fD1y,fZ1,fD2x,fD2y,fZ2);
00097 if (Math<Real>::FAbs(fDet3) >= fScaledUncertainty)
00098 {
00099 return (fDet3 < (Real)0.0 ? 1 : (fDet3 > (Real)0.0 ? -1 : 0));
00100 }
00101
00102 return m_kRQuery.ToCircumcircle(rkP,iV0,iV1,iV2);
00103 }
00104
00105 }