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