#ifndef GR_Geometry
#define GR_Geometry 1

#include "GR_config.h"
#include "GR_Vec.h"
#include "GR_Vertex.h"

/// Distance between two points
inline double dDist(const Vert * const pV0, const Vert * const pV1)
{
  assert(pV1->iSpaceDimen() == pV0->iSpaceDimen());
  if (pV0->iSpaceDimen() == 2) {
    return dDIST2D(pV0->adCoords(), pV1->adCoords());
  }
  else {
    return dDIST3D(pV0->adCoords(), pV1->adCoords());
  }
}    

/// Normal of an edge in 2D
void vNormal(const double adA[2], const double adB[2], double adResult[2]);
/// Normal of a triangle in 2D
void vNormal2D(const double adA[2], const double adB[2],
	       const double adC[2], double * const adResult);
/// Normal of a triangle in 3D
void vNormal3D(const double adA[3], const double adB[3],
	       const double adC[3], double * const adResult);
///
int iOrient3D(const Face* const pF, const double ad[3]);
///
int iOrient3D(const Face* const pF, const Vert* const pV);
///
int iOrient3D(const Vert* const pVA, const Vert* const pVB,
	      const Vert* const pVC, const Vert* const pVD);
///
int iOrient3D(const double adA[3], const double adB[3],
	      const double adC[3], const double adD[3]); 
///
int iInsphere(const Vert* const pVA, const Vert* const pVB,
	      const Vert* const pVC, const Vert* const pVD,
	      const Vert* const pVE);
///
int iInsphere(const double adA[3], const double adB[3],
	      const double adC[3], const double adD[3],
	      const double adE[3]);
///
int iIsInTet(const Vert* const pV,     const Vert* const pVertA,
	     const Vert* const pVertB,	const Vert* const pVertC,
	     const Vert* const pVertD);
///
int iCoplanarInTet(const Vert* const pV,     const Vert* const pVertA,
		   const Vert* const pVertB, const Vert* const pVertC,
		   const Vert* const pVertD);
///
int iIsInTri(const Vert* const pV,     const Vert* const pVertA,
	     const Vert* const pVertB,	const Vert* const pVertC);
///
int iOrient2D(const Vert* const pVA, const Vert* const pVB,
	      const Vert* const pVC);
///
int iOrient2D(const double adA[2], const double adB[2],
	      const double adC[2]);
/// int iOrient2D(const EdgeFace* const pFE, const double ad[3]);
int iIncircle(const Vert* const pVA, const Vert* const pVB,
	      const Vert* const pVC, const Vert* const pVD);
int iIncircle(const double adA[2], const double adB[2],
	      const double adC[2], const double adD[2]);
///
int iIsReflex(const EdgeFace* const pF);

#endif
