IOSS 2.0
Loading...
Searching...
No Matches
vector3d.h
Go to the documentation of this file.
1/*
2 * Copyright(C) 1999-2020, 2022, 2023 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#pragma once
9
11{
12public:
13 // construction
15 vector3d(double X, double Y, double Z);
16 explicit vector3d(double location[3]);
17 vector3d(const vector3d &from);
18
19 double x{}, y{}, z{};
20
22 bool operator==(const vector3d &from) const;
23 bool operator!=(const vector3d &from) const;
24 void set(double X, double Y, double Z);
25 void set(const double location[3]);
27
28 vector3d operator-() const;
29
30 vector3d &operator+=(const vector3d &from);
31 vector3d &operator-=(const vector3d &from);
32 vector3d &operator*=(double scalar);
33 vector3d &operator/=(double scalar);
34
35 double length() const;
36 double normalize(double tolerance = 1e-06);
37 vector3d cross(const vector3d &from) const;
38 static vector3d plane_normal(const vector3d &v1, const vector3d &v2, const vector3d &v3);
39};
40
41vector3d operator*(double scalar, const vector3d &from);
42vector3d operator*(const vector3d &lhs, double scalar);
43vector3d operator/(const vector3d &lhs, double scalar);
44
45vector3d operator+(const vector3d &lhs, const vector3d &rhs);
46vector3d operator-(const vector3d &lhs, const vector3d &rhs);
47
48//----------------------------------------------------------------------------
49inline vector3d vector3d::cross(const vector3d &from) const
50{
51 return {y * from.z - z * from.y, z * from.x - x * from.z, x * from.y - y * from.x};
52}
53//----------------------------------------------------------------------------
55{
56 x += from.x;
57 y += from.y;
58 z += from.z;
59 return *this;
60}
61//----------------------------------------------------------------------------
63{
64 x -= from.x;
65 y -= from.y;
66 z -= from.z;
67 return *this;
68}
69//----------------------------------------------------------------------------
70inline vector3d &vector3d::operator*=(double scalar)
71{
72 x *= scalar;
73 y *= scalar;
74 z *= scalar;
75 return *this;
76}
Definition vector3d.h:11
vector3d & operator=(const vector3d &from)
void set(double X, double Y, double Z)
Definition vector3d.C:23
vector3d & operator+=(const vector3d &from)
Definition vector3d.h:54
double normalize(double tolerance=1e-06)
Definition vector3d.C:114
double y
Definition vector3d.h:19
bool operator!=(const vector3d &from) const
Definition vector3d.C:52
vector3d(const vector3d &from)
double length() const
Definition vector3d.C:112
vector3d operator-() const
Definition vector3d.C:75
vector3d & operator-=(const vector3d &from)
Definition vector3d.h:62
vector3d & operator/=(double scalar)
Definition vector3d.C:96
double z
Definition vector3d.h:19
vector3d & reverse()
Definition vector3d.C:39
static vector3d plane_normal(const vector3d &v1, const vector3d &v2, const vector3d &v3)
Definition vector3d.C:130
bool operator==(const vector3d &from) const
Definition vector3d.C:47
vector3d cross(const vector3d &from) const
Definition vector3d.h:49
vector3d & operator*=(double scalar)
Definition vector3d.h:70
double x
Definition vector3d.h:19
vector3d operator/(const vector3d &lhs, double scalar)
Definition vector3d.C:87
vector3d operator*(double scalar, const vector3d &from)
Definition vector3d.C:81
vector3d operator-(const vector3d &lhs, const vector3d &rhs)
Definition vector3d.C:63
vector3d operator+(const vector3d &lhs, const vector3d &rhs)
Definition vector3d.C:57