Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Misc/Vector3D.cpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
27 #include "Vector3D.hpp"
28 #include "MsqError.hpp"
29 
30 #ifdef MSQ_USE_OLD_IO_HEADERS
31 # include <iostream.h>
32 #else
33 # include <iostream>
34 #endif
35 
36 #include <math.h>
37 
38 #ifdef HAVE_IEEEFP
39 # include <ieeefp.h>
40 #endif
41 
42 namespace Mesquite {
43 
44 msq_stdio::ostream& operator<<(msq_stdio::ostream &s, const Mesquite::Vector3D &v)
45 {
46  return s << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' << msq_stdio::endl;
47 }
48 
50  const Vector3D &rhs,
51  MsqError& err)
52  {
53  double len1 = lhs.length();
54  double len2 = rhs.length();
55  double angle_cos = (lhs % rhs)/(len1 * len2);
56  if (!finite( angle_cos ))
57  {
59  return 0.0;
60  }
61 
62  // Adjust the cosine if slightly out of range
63  if ((angle_cos > 1.0) && (angle_cos < 1.0001))
64  {
65  angle_cos = 1.0;
66  }
67  else if (angle_cos < -1.0 && angle_cos > -1.0001)
68  {
69  angle_cos = -1.0;
70  }
71 
72  return msq_stdc::acos(angle_cos);
73  }
74 
75 }
void const int char const int long int long int len2
Definition: mapptr.h:80
static double interior_angle(const Vector3D &a, const Vector3D &b, MsqError &err)
Used to hold the error state and return it to the application.
NT rhs
double s
Definition: blastest.C:80
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void const int char const int long int len1
Definition: mapptr.h:80
msq_stdio::ostream & operator<<(msq_stdio::ostream &s, const Matrix3D &A)
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051