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 Query3Int64<Real>::Query3Int64 (int iVQuantity, const Vector3<Real>* akVertex)
00022 :
00023 Query3<Real>(iVQuantity,akVertex)
00024 {
00025 }
00026
00027 template <class Real>
00028 Query::Type Query3Int64<Real>::GetType () const
00029 {
00030 return Query::QT_INT64;
00031 }
00032
00033 template <class Real>
00034 int Query3Int64<Real>::ToPlane (const Vector3<Real>& rkP, int iV0, int iV1,
00035 int iV2) const
00036 {
00037 const Vector3<Real>& rkV0 = m_akVertex[iV0];
00038 const Vector3<Real>& rkV1 = m_akVertex[iV1];
00039 const Vector3<Real>& rkV2 = m_akVertex[iV2];
00040
00041 Integer64 iX0 = (Integer64)rkP[0] - (Integer64)rkV0[0];
00042 Integer64 iY0 = (Integer64)rkP[1] - (Integer64)rkV0[1];
00043 Integer64 iZ0 = (Integer64)rkP[2] - (Integer64)rkV0[2];
00044 Integer64 iX1 = (Integer64)rkV1[0] - (Integer64)rkV0[0];
00045 Integer64 iY1 = (Integer64)rkV1[1] - (Integer64)rkV0[1];
00046 Integer64 iZ1 = (Integer64)rkV1[2] - (Integer64)rkV0[2];
00047 Integer64 iX2 = (Integer64)rkV2[0] - (Integer64)rkV0[0];
00048 Integer64 iY2 = (Integer64)rkV2[1] - (Integer64)rkV0[1];
00049 Integer64 iZ2 = (Integer64)rkV2[2] - (Integer64)rkV0[2];
00050
00051 Integer64 iDet3 = Det3(iX0,iY0,iZ0,iX1,iY1,iZ1,iX2,iY2,iZ2);
00052 return (iDet3 > 0 ? +1 : (iDet3 < 0 ? -1 : 0));
00053 }
00054
00055 template <class Real>
00056 int Query3Int64<Real>::ToCircumsphere (const Vector3<Real>& rkP, int iV0,
00057 int iV1, int iV2, int iV3) const
00058 {
00059 const Vector3<Real>& rkV0 = m_akVertex[iV0];
00060 const Vector3<Real>& rkV1 = m_akVertex[iV1];
00061 const Vector3<Real>& rkV2 = m_akVertex[iV2];
00062 const Vector3<Real>& rkV3 = m_akVertex[iV3];
00063
00064 Integer64 aiP[3] = { (Integer64)rkP[0], (Integer64)rkP[1],
00065 (Integer64)rkP[2] };
00066 Integer64 aiV0[3] = { (Integer64)rkV0[0], (Integer64)rkV0[1],
00067 (Integer64)rkV0[2] };
00068 Integer64 aiV1[3] = { (Integer64)rkV1[0], (Integer64)rkV1[1],
00069 (Integer64)rkV1[2] };
00070 Integer64 aiV2[3] = { (Integer64)rkV2[0], (Integer64)rkV2[1],
00071 (Integer64)rkV2[2] };
00072 Integer64 aiV3[3] = { (Integer64)rkV3[0], (Integer64)rkV3[1],
00073 (Integer64)rkV3[2] };
00074
00075 Integer64 iS0x = aiV0[0] + aiP[0];
00076 Integer64 iD0x = aiV0[0] - aiP[0];
00077 Integer64 iS0y = aiV0[1] + aiP[1];
00078 Integer64 iD0y = aiV0[1] - aiP[1];
00079 Integer64 iS0z = aiV0[2] + aiP[2];
00080 Integer64 iD0z = aiV0[2] - aiP[2];
00081 Integer64 iS1x = aiV1[0] + aiP[0];
00082 Integer64 iD1x = aiV1[0] - aiP[0];
00083 Integer64 iS1y = aiV1[1] + aiP[1];
00084 Integer64 iD1y = aiV1[1] - aiP[1];
00085 Integer64 iS1z = aiV1[2] + aiP[2];
00086 Integer64 iD1z = aiV1[2] - aiP[2];
00087 Integer64 iS2x = aiV2[0] + aiP[0];
00088 Integer64 iD2x = aiV2[0] - aiP[0];
00089 Integer64 iS2y = aiV2[1] + aiP[1];
00090 Integer64 iD2y = aiV2[1] - aiP[1];
00091 Integer64 iS2z = aiV2[2] + aiP[2];
00092 Integer64 iD2z = aiV2[2] - aiP[2];
00093 Integer64 iS3x = aiV3[0] + aiP[0];
00094 Integer64 iD3x = aiV3[0] - aiP[0];
00095 Integer64 iS3y = aiV3[1] + aiP[1];
00096 Integer64 iD3y = aiV3[1] - aiP[1];
00097 Integer64 iS3z = aiV3[2] + aiP[2];
00098 Integer64 iD3z = aiV3[2] - aiP[2];
00099 Integer64 iW0 = iS0x*iD0x + iS0y*iD0y + iS0z*iD0z;
00100 Integer64 iW1 = iS1x*iD1x + iS1y*iD1y + iS1z*iD1z;
00101 Integer64 iW2 = iS2x*iD2x + iS2y*iD2y + iS2z*iD2z;
00102 Integer64 iW3 = iS3x*iD3x + iS3y*iD3y + iS3z*iD3z;
00103 Integer64 iDet4 = Det4(iD0x,iD0y,iD0z,iW0,iD1x,iD1y,iD1z,iW1,iD2x,
00104 iD2y,iD2z,iW2,iD3x,iD3y,iD3z,iW3);
00105
00106 return (iDet4 > 0 ? 1 : (iDet4 < 0 ? -1 : 0));
00107 }
00108
00109 template <class Real>
00110 Integer64 Query3Int64<Real>::Dot (Integer64 iX0, Integer64 iY0, Integer64 iZ0,
00111 Integer64 iX1, Integer64 iY1, Integer64 iZ1)
00112 {
00113 return iX0*iX1 + iY0*iY1 + iZ0*iZ1;
00114 }
00115
00116 template <class Real>
00117 Integer64 Query3Int64<Real>::Det3 (Integer64 iX0, Integer64 iY0,
00118 Integer64 iZ0, Integer64 iX1, Integer64 iY1, Integer64 iZ1,
00119 Integer64 iX2, Integer64 iY2, Integer64 iZ2)
00120 {
00121 Integer64 iC00 = iY1*iZ2 - iY2*iZ1;
00122 Integer64 iC01 = iY2*iZ0 - iY0*iZ2;
00123 Integer64 iC02 = iY0*iZ1 - iY1*iZ0;
00124 return iX0*iC00 + iX1*iC01 + iX2*iC02;
00125 }
00126
00127 template <class Real>
00128 Integer64 Query3Int64<Real>::Det4 (Integer64 iX0, Integer64 iY0,
00129 Integer64 iZ0, Integer64 iW0, Integer64 iX1, Integer64 iY1, Integer64 iZ1,
00130 Integer64 iW1, Integer64 iX2, Integer64 iY2, Integer64 iZ2, Integer64 iW2,
00131 Integer64 iX3, Integer64 iY3, Integer64 iZ3, Integer64 iW3)
00132 {
00133 Integer64 iA0 = iX0*iY1 - iX1*iY0;
00134 Integer64 iA1 = iX0*iY2 - iX2*iY0;
00135 Integer64 iA2 = iX0*iY3 - iX3*iY0;
00136 Integer64 iA3 = iX1*iY2 - iX2*iY1;
00137 Integer64 iA4 = iX1*iY3 - iX3*iY1;
00138 Integer64 iA5 = iX2*iY3 - iX3*iY2;
00139 Integer64 iB0 = iZ0*iW1 - iZ1*iW0;
00140 Integer64 iB1 = iZ0*iW2 - iZ2*iW0;
00141 Integer64 iB2 = iZ0*iW3 - iZ3*iW0;
00142 Integer64 iB3 = iZ1*iW2 - iZ2*iW1;
00143 Integer64 iB4 = iZ1*iW3 - iZ3*iW1;
00144 Integer64 iB5 = iZ2*iW3 - iZ3*iW2;
00145 return iA0*iB5-iA1*iB4+iA2*iB3+iA3*iB2-iA4*iB1+iA5*iB0;
00146 }
00147
00148 }