Wm4Query2Int64.inl

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2007
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 // The license applies to versions 0 through 4 of Wild Magic.
00014 //
00015 // Version: 4.0.0 (2006/06/28)
00016 
00017 namespace Wm4
00018 {
00019 //----------------------------------------------------------------------------
00020 template <class Real>
00021 Query2Int64<Real>::Query2Int64 (int iVQuantity, const Vector2<Real>* akVertex)
00022     :
00023     Query2<Real>(iVQuantity,akVertex)
00024 {
00025 }
00026 //----------------------------------------------------------------------------
00027 template <class Real>
00028 Query::Type Query2Int64<Real>::GetType () const
00029 {
00030     return Query::QT_INT64;
00031 }
00032 //----------------------------------------------------------------------------
00033 template <class Real>
00034 int Query2Int64<Real>::ToLine (const Vector2<Real>& rkP, int iV0, int iV1)
00035     const
00036 {
00037     const Vector2<Real>& rkV0 = m_akVertex[iV0];
00038     const Vector2<Real>& rkV1 = m_akVertex[iV1];
00039 
00040     Integer64 iX0 = (Integer64)rkP[0] - (Integer64)rkV0[0];
00041     Integer64 iY0 = (Integer64)rkP[1] - (Integer64)rkV0[1];
00042     Integer64 iX1 = (Integer64)rkV1[0] - (Integer64)rkV0[0];
00043     Integer64 iY1 = (Integer64)rkV1[1] - (Integer64)rkV0[1];
00044 
00045     Integer64 iDet2 = Det2(iX0,iY0,iX1,iY1);
00046     return (iDet2 > 0 ? +1 : (iDet2 < 0 ? -1 : 0));
00047 }
00048 //----------------------------------------------------------------------------
00049 template <class Real>
00050 int Query2Int64<Real>::ToCircumcircle (const Vector2<Real>& rkP, int iV0,
00051     int iV1, int iV2) const
00052 {
00053     const Vector2<Real>& rkV0 = m_akVertex[iV0];
00054     const Vector2<Real>& rkV1 = m_akVertex[iV1];
00055     const Vector2<Real>& rkV2 = m_akVertex[iV2];
00056 
00057     Integer64 aiP[2] = { (Integer64)rkP[0], (Integer64)rkP[1] };
00058     Integer64 aiV0[2] = { (Integer64)rkV0[0], (Integer64)rkV0[1] };
00059     Integer64 aiV1[2] = { (Integer64)rkV1[0], (Integer64)rkV1[1] };
00060     Integer64 aiV2[2] = { (Integer64)rkV2[0], (Integer64)rkV2[1] };
00061 
00062     Integer64 iS0x = aiV0[0] + aiP[0];
00063     Integer64 iD0x = aiV0[0] - aiP[0];
00064     Integer64 iS0y = aiV0[1] + aiP[1];
00065     Integer64 iD0y = aiV0[1] - aiP[1];
00066     Integer64 iS1x = aiV1[0] + aiP[0];
00067     Integer64 iD1x = aiV1[0] - aiP[0];
00068     Integer64 iS1y = aiV1[1] + aiP[1];
00069     Integer64 iD1y = aiV1[1] - aiP[1];
00070     Integer64 iS2x = aiV2[0] + aiP[0];
00071     Integer64 iD2x = aiV2[0] - aiP[0];
00072     Integer64 iS2y = aiV2[1] + aiP[1];
00073     Integer64 iD2y = aiV2[1] - aiP[1];
00074     Integer64 iZ0 = iS0x*iD0x + iS0y*iD0y;
00075     Integer64 iZ1 = iS1x*iD1x + iS1y*iD1y;
00076     Integer64 iZ2 = iS2x*iD2x + iS2y*iD2y;
00077     Integer64 iDet3 = Det3(iD0x,iD0y,iZ0,iD1x,iD1y,iZ1,iD2x,iD2y,iZ2);
00078     return (iDet3 < 0 ? 1 : (iDet3 > 0 ? -1 : 0));
00079 }
00080 //----------------------------------------------------------------------------
00081 template <class Real>
00082 Integer64 Query2Int64<Real>::Dot (Integer64 iX0, Integer64 iY0, Integer64 iX1,
00083     Integer64 iY1)
00084 {
00085     return iX0*iX1 + iY0*iY1;
00086 }
00087 //----------------------------------------------------------------------------
00088 template <class Real>
00089 Integer64 Query2Int64<Real>::Det2 (Integer64 iX0, Integer64 iY0,
00090     Integer64 iX1, Integer64 iY1)
00091 {
00092     return iX0*iY1 - iX1*iY0;
00093 }
00094 //----------------------------------------------------------------------------
00095 template <class Real>
00096 Integer64 Query2Int64<Real>::Det3 (Integer64 iX0, Integer64 iY0,
00097     Integer64 iZ0, Integer64 iX1, Integer64 iY1, Integer64 iZ1, Integer64 iX2,
00098     Integer64 iY2, Integer64 iZ2)
00099 {
00100     Integer64 iC00 = iY1*iZ2 - iY2*iZ1;
00101     Integer64 iC01 = iY2*iZ0 - iY0*iZ2;
00102     Integer64 iC02 = iY0*iZ1 - iY1*iZ0;
00103     return iX0*iC00 + iX1*iC01 + iX2*iC02;
00104 }
00105 //----------------------------------------------------------------------------
00106 } //namespace Wm4

Generated on Wed Nov 23 19:01:07 2011 for FreeCAD by  doxygen 1.6.1