Debian Codegraph @

packages/seacas/applications/ejoin/EJ_vector3d.h

raw
1 // Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 #pragma once
7
8 class vector3d
9 {
10 public:
11 vector3d() = default;
12 vector3d(double X, double Y, double Z);
13 explicit vector3d(const double location[3]);
14
15 double x{}, y{}, z{};
16
17 void set(double X, double Y, double Z);
18 void set(const double location[3]);
19 vector3d &reverse();
20
21 vector3d operator-() const;
22
23 vector3d &operator+=(const vector3d &from);
24 vector3d &operator-=(const vector3d &from);
25
26 vector3d &operator+=(double scalar);
27 vector3d &operator-=(double scalar);
28 vector3d &operator*=(double scalar);
29 vector3d &operator/=(double scalar);
30
31 friend bool operator==(const vector3d &lhs, const vector3d &rhs);
32 friend bool operator!=(const vector3d &lhs, const vector3d &rhs);
33
34 friend vector3d operator*(double scalar, const vector3d &from);
35 friend vector3d operator*(const vector3d &lhs, double scalar);
36 friend vector3d operator/(const vector3d &lhs, double scalar);
37
38 friend vector3d operator+(const vector3d &lhs, const vector3d &rhs);
39 friend vector3d operator-(const vector3d &lhs, const vector3d &rhs);
40
41 double length() const;
42 vector3d cross(const vector3d &from) const;
43 };
44
45 //----------------------------------------------------------------------------
46 inline vector3d vector3d::cross(const vector3d &from) const
47 {
48 return {y * from.z - z * from.y, z * from.x - x * from.z, x * from.y - y * from.x};
49 }
50 //----------------------------------------------------------------------------
51 inline vector3d &vector3d::operator+=(const vector3d &from)
52 {
53 x += from.x;
54 y += from.y;
55 z += from.z;
56 return *this;
57 }
58 //----------------------------------------------------------------------------
59 inline vector3d &vector3d::operator-=(const vector3d &from)
60 {
61 x -= from.x;
62 y -= from.y;
63 z -= from.z;
64 return *this;
65 }
66 //----------------------------------------------------------------------------
67 inline vector3d &vector3d::operator*=(double scalar)
68 {
69 x *= scalar;
70 y *= scalar;
71 z *= scalar;
72 return *this;
73 }
74
75 //----------------------------------------------------------------------------
76 inline vector3d &vector3d::operator+=(double scalar)
77 {
78 x += scalar;
79 y += scalar;
80 z += scalar;
81 return *this;
82 }
83
84 //----------------------------------------------------------------------------
85 inline vector3d &vector3d::operator-=(double scalar)
86 {
87 x -= scalar;
88 y -= scalar;
89 z -= scalar;
90 return *this;
91 }