/*
    C++ Mesh Generation Library
    Copyright (c) 2000echet <eric at bechet dot ca>

    This file is part of the C++ Mesh Generation Library.

    See the NOTICE & LICENSE files for conditions.
*/
//---------------------------------------------------------------------------
#ifndef MESH_GLOBALS_H
#define MESH_GLOBALS_H
//---------------------------------------------------------------------------



#include "mesh_const.h"
#include "linear_algebra.h"

/// converts a double to a string with fortran style coding "x.yyyyDee"
char* fortran_str ( double d, char buf[] );
/// checks if a node is inside a triangle in 3D
bool Is_Inside_Triangle3D ( double n[3], double ele[3][3], double param[3] );

/// checks if a node is inside a line (n dim)
template <class V> bool Is_On_Line ( V n,V p1,V p2, double param[2] )
{
  Vector V1 ( 3,p1,p2 ),V2 ( 3,p1,n );
  double scal,nrm1,nrm2;
  scal=V1*V2;
  nrm1=V1.Norm();
  nrm1*=nrm1;
  nrm2=V2.Norm();
  nrm2*=nrm2;
  param[0]=scal/nrm1;
  param[1]=sqrt ( nrm2/nrm1-param[0]*param[0] );

  if ( ( param[0]<1.0001 ) && ( param[0]>-0.0001 ) && ( fabs ( param[1] ) <0.0001 ) )
  {
    return true;
  }
  else
  {
    return false;
  }
}

#endif // MESH_GLOBALS_H



 
