forked from sandialabs/verdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVerdictVector.cpp
82 lines (65 loc) · 1.86 KB
/
VerdictVector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*=========================================================================
Module: VerdictVector.cpp
Copyright 2006 National Technology & Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* VerdictVector.cpp contains implementation of Vector operations
*
* This file is part of VERDICT
*
*/
#include "verdict.h"
#include <math.h>
#include "VerdictVector.hpp"
#include <float.h>
#if defined(__BORLANDC__)
#pragma warn -8004 /* "assigned a value that is never used" */
#endif
namespace VERDICT_NAMESPACE
{
// scale the length of the vector to be the new_length
// unused
//VerdictVector &VerdictVector::length(const double new_length)
//{
// double len = this->length();
// xVal *= new_length / len;
// yVal *= new_length / len;
// zVal *= new_length / len;
// return *this;
//}
double VerdictVector::interior_angle(const VerdictVector &otherVector)
{
double cosAngle=0., angleRad=0., len1, len2=0.;
if (((len1 = this->length()) > 0) && ((len2 = otherVector.length()) > 0))
cosAngle = VerdictVector::Dot(*this , otherVector)/(len1 * len2);
else
{
assert(len1 > 0);
assert(len2 > 0);
}
if ((cosAngle > 1.0) && (cosAngle < 1.0001))
{
cosAngle = 1.0;
angleRad = acos(cosAngle);
}
else if (cosAngle < -1.0 && cosAngle > -1.0001)
{
cosAngle = -1.0;
angleRad = acos(cosAngle);
}
else if (cosAngle >= -1.0 && cosAngle <= 1.0)
angleRad = acos(cosAngle);
else
{
assert(cosAngle < 1.0001 && cosAngle > -1.0001);
}
return( (angleRad * 180.) / VERDICT_PI );
}
VerdictVector::VerdictVector(const double xyz[3])
: xVal(xyz[0]), yVal(xyz[1]), zVal(xyz[2])
{}
} // namespace verdict