Test-vectorTools.C
Go to the documentation of this file.
1 #include "vector.H"
2 #include "IOstreams.H"
3 #include "vectorTools.H"
4 #include "unitConversion.H"
5 
6 using namespace Foam;
7 
8 
9 void test(const vector& a, const vector& b, const scalar tolerance)
10 {
11  Info<< "Vectors " << a << " and " << b
12  << " are (to tolerance of " << tolerance << "): ";
13 
14  if (vectorTools::areParallel(a, b, tolerance))
15  Info<< " parallel ";
16 
17  if (vectorTools::areOrthogonal(a, b, tolerance))
18  Info<< " orthogonal ";
19 
20  if (vectorTools::areAcute(a, b))
21  Info<< " acute ";
22 
23  if (vectorTools::areObtuse(a, b))
24  Info<< " obtuse ";
25 
26  Info<< ", angle = " << vectorTools::degAngleBetween(a, b);
27 
28  Info<< endl;
29 }
30 
31 
32 int main()
33 {
34  vector a(1.0, 1.0, 1.0);
35  vector b(2.0, 2.0, 2.0);
36 
37  test(a, b, 0.0);
38  test(a, b, VSMALL);
39  test(a, b, SMALL);
40  test(a, b, 1e-3);
41  test(a, b, 1e-1);
42 
43  a = vector(1,0,0);
44  b = vector(0,2,0);
45 
46  test(a, b, 0.0);
47  test(a, b, VSMALL);
48  test(a, b, SMALL);
49  test(a, b, 1e-3);
50  test(a, b, 1e-1);
51 
52  a = vector(1,0,0);
53  b = vector(-1,0,0);
54 
55  test(a, b, 0.0);
56  test(a, b, VSMALL);
57  test(a, b, SMALL);
58  test(a, b, 1e-3);
59  test(a, b, 1e-1);
60 
61  a = vector(1,0,0);
62  b = vector(-1,2,0);
63 
64  test(a, b, 0.0);
65  test(a, b, VSMALL);
66  test(a, b, SMALL);
67  test(a, b, 1e-3);
68  test(a, b, 1e-1);
69 
70  return 0;
71 }
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
test
void test(const vector &a, const vector &b, const scalar tolerance)
Definition: Test-vectorTools.C:9
unitConversion.H
Unit conversion functions.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::vectorTools::areOrthogonal
bool areOrthogonal(const Vector< T > &a, const Vector< T > &b, const T &tolerance=SMALL)
Test if a and b are orthogonal: a.b = 0.
Definition: vectorTools.H:71
Foam::vectorTools::areObtuse
bool areObtuse(const Vector< T > &a, const Vector< T > &b)
Test if angle between a and b is obtuse: a.b < 0.
Definition: vectorTools.H:94
main
int main()
Definition: Test-vectorTools.C:32
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::Info
messageStream Info
Foam::vectorTools::areAcute
bool areAcute(const Vector< T > &a, const Vector< T > &b)
Test if angle between a and b is acute: a.b > 0.
Definition: vectorTools.H:83
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::vectorTools::areParallel
bool areParallel(const Vector< T > &a, const Vector< T > &b, const T &tolerance=SMALL)
Test if a and b are parallel: a^b = 0.
Definition: vectorTools.H:54
Foam::Vector< scalar >
vector.H
Foam::vectorTools::degAngleBetween
T degAngleBetween(const Vector< T > &a, const Vector< T > &b, const T &tolerance=SMALL)
Calculate angle between a and b in degrees.
Definition: vectorTools.H:135
vectorTools.H