IOSS  2.0
vector3d.h
Go to the documentation of this file.
1 /*
2  * Copyright(C) 1999-2020 National Technology & Engineering Solutions
3  * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4  * NTESS, the U.S. Government retains certain rights in this software.
5  *
6  * See packages/seacas/LICENSE for details
7  */
8 #ifndef VECTOR3D
9 #define VECTOR3D
10 
11 class vector3d
12 {
13 public:
14  // construction
16  vector3d(double X, double Y, double Z);
17  explicit vector3d(double location[3]);
18  vector3d(const vector3d &from);
19 
20  double x{}, y{}, z{};
21 
22  vector3d &operator=(const vector3d &from);
23  bool operator==(const vector3d &from) const;
24  bool operator!=(const vector3d &from) const;
25  void set(double X, double Y, double Z);
26  void set(const double location[3]);
27  vector3d &reverse();
28 
29  vector3d operator-() const;
30 
31  vector3d &operator+=(const vector3d &from);
32  vector3d &operator-=(const vector3d &from);
33  vector3d &operator*=(double scalar);
34  vector3d &operator/=(double scalar);
35 
36  double length() const;
37  double normalize(double tolerance = 1e-06);
38  vector3d cross(const vector3d &from) const;
39  static vector3d plane_normal(const vector3d &v1, const vector3d &v2, const vector3d &v3);
40 };
41 
42 vector3d operator*(double scalar, const vector3d &from);
43 vector3d operator*(const vector3d &lhs, double scalar);
44 vector3d operator/(const vector3d &lhs, double scalar);
45 
46 vector3d operator+(const vector3d &lhs, const vector3d &rhs);
47 vector3d operator-(const vector3d &lhs, const vector3d &rhs);
48 
49 //----------------------------------------------------------------------------
50 inline vector3d vector3d::cross(const vector3d &from) const
51 {
52  return vector3d(y * from.z - z * from.y, z * from.x - x * from.z, x * from.y - y * from.x);
53 }
54 //----------------------------------------------------------------------------
56 {
57  x += from.x;
58  y += from.y;
59  z += from.z;
60  return *this;
61 }
62 //----------------------------------------------------------------------------
64 {
65  x -= from.x;
66  y -= from.y;
67  z -= from.z;
68  return *this;
69 }
70 //----------------------------------------------------------------------------
72 {
73  x *= scalar;
74  y *= scalar;
75  z *= scalar;
76  return *this;
77 }
78 
79 #endif
vector3d::cross
vector3d cross(const vector3d &from) const
Definition: vector3d.h:50
vector3d::operator+=
vector3d & operator+=(const vector3d &from)
Definition: vector3d.h:55
vector3d::operator==
bool operator==(const vector3d &from) const
Definition: vector3d.C:47
vector3d::operator/=
vector3d & operator/=(double scalar)
Definition: vector3d.C:96
vector3d::set
void set(double X, double Y, double Z)
Definition: vector3d.C:23
anonymous_namespace{Ioss_ConcreteVariableType.C}::Y
const std::string Y()
Definition: Ioss_ConcreteVariableType.C:15
vector3d::reverse
vector3d & reverse()
Definition: vector3d.C:39
vector3d::z
double z
Definition: vector3d.h:20
operator*
vector3d operator*(double scalar, const vector3d &from)
Definition: vector3d.C:81
vector3d::vector3d
vector3d()
vector3d
Definition: vector3d.h:12
vector3d::vector3d
vector3d(const vector3d &from)
operator+
vector3d operator+(const vector3d &lhs, const vector3d &rhs)
Definition: vector3d.C:57
operator/
vector3d operator/(const vector3d &lhs, double scalar)
Definition: vector3d.C:87
vector3d::operator=
vector3d & operator=(const vector3d &from)
anonymous_namespace{Ioss_ConcreteVariableType.C}::scalar
const std::string scalar()
Definition: Ioss_ConcreteVariableType.C:31
vector3d::operator*=
vector3d & operator*=(double scalar)
Definition: vector3d.h:71
operator-
vector3d operator-(const vector3d &lhs, const vector3d &rhs)
Definition: vector3d.C:63
vector3d::x
double x
Definition: vector3d.h:20
vector3d::operator!=
bool operator!=(const vector3d &from) const
Definition: vector3d.C:52
vector3d::normalize
double normalize(double tolerance=1e-06)
Definition: vector3d.C:114
anonymous_namespace{Ioss_ConcreteVariableType.C}::X
const std::string X()
Definition: Ioss_ConcreteVariableType.C:14
vector3d::operator-=
vector3d & operator-=(const vector3d &from)
Definition: vector3d.h:63
anonymous_namespace{Ioss_ConcreteVariableType.C}::Z
const std::string Z()
Definition: Ioss_ConcreteVariableType.C:16
vector3d::length
double length() const
Definition: vector3d.C:112
vector3d::y
double y
Definition: vector3d.h:20
vector3d::operator-
vector3d operator-() const
Definition: vector3d.C:75
vector3d::plane_normal
static vector3d plane_normal(const vector3d &v1, const vector3d &v2, const vector3d &v3)
Definition: vector3d.C:130