Code_TYMPAN  4.4.0
Industrial site acoustic simulation
NxVec3.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #ifndef NXVEC3_H
17 #define NXVEC3_H
18 #include <cmath>
19 
20 #define NxReal double
21 
22 class NxVec3
23 {
24 public:
25  NxVec3();
26  NxVec3(NxReal a);
27  NxVec3(NxReal nx, NxReal ny, NxReal nz);
28  NxVec3(const NxReal v[]);
29  NxVec3(const NxReal v[], bool normalized);
30  NxVec3(const NxVec3& v);
31  NxVec3(const NxVec3& v, bool normalized);
32  const NxVec3& operator=(const NxVec3&);
33  const NxReal* get() const;
34  NxReal* get();
35  bool operator<(const NxVec3&) const;
36  bool operator==(const NxVec3&) const;
37  bool operator!=(const NxVec3&) const;
38  void set(const NxVec3&);
39  void setx(const NxReal& d);
40  void sety(const NxReal& d);
41  void setz(const NxReal& d);
42  void setNegative(const NxVec3& a);
43  void setNegative();
44  void set(NxReal, NxReal, NxReal);
45  void set(NxReal);
46  void zero();
49 
50  void add(const NxVec3& a, const NxVec3& b);
51  void subtract(const NxVec3& a, const NxVec3& b);
52  void multiply(NxReal s, const NxVec3& a);
53  void arrayMultiply(const NxVec3& a, const NxVec3& b);
54  void multiplyAdd(NxReal s, const NxVec3& a, const NxVec3& b);
55  NxReal normalize();
56  void setMagnitude(NxReal);
57  bool isFinite() const;
58  NxReal dot(const NxVec3& other) const;
59  bool sameDirection(const NxVec3&) const;
60  NxReal magnitude() const;
61  NxReal distance(const NxVec3&) const;
62  void cross(const NxVec3& left, const NxVec3& right);
63  void cross(const NxVec3& left, const NxVec3& right, bool normalized);
64  bool equals(const NxVec3&, NxReal epsilon) const;
65  void rotate(NxReal angle, const NxVec3& axe);
66  void rotate(NxReal sin_angle, NxReal cos_angle, const NxVec3& axe);
67  void rotate(const NxVec3& axe);
68  NxVec3 operator-() const;
69  NxVec3 operator+(const NxVec3& v) const;
70  NxVec3 operator-(const NxVec3& v) const;
71  NxVec3 operator*(NxReal f) const;
72  NxVec3 operator/(NxReal f) const;
73  NxVec3& operator+=(const NxVec3& v);
74  NxVec3& operator-=(const NxVec3& v);
77  NxVec3 cross(const NxVec3& v) const;
78  NxVec3 operator^(const NxVec3& v) const;
79  NxReal operator|(const NxVec3& v) const;
80  NxReal x, y, z;
81 };
82 
83 #endif
NxReal s
Definition: NxVec3.cpp:317
#define NxReal
Definition: NxVec3.h:20
Definition: NxVec3.h:23
NxReal operator|(const NxVec3 &v) const
Definition: NxVec3.cpp:308
NxVec3 & operator+=(const NxVec3 &v)
Definition: NxVec3.cpp:261
void subtract(const NxVec3 &a, const NxVec3 &b)
Definition: NxVec3.cpp:131
const NxVec3 & operator=(const NxVec3 &)
Definition: NxVec3.cpp:41
NxVec3 operator+(const NxVec3 &v) const
Definition: NxVec3.cpp:240
void setMagnitude(NxReal)
Definition: NxVec3.cpp:172
bool sameDirection(const NxVec3 &) const
Definition: NxVec3.cpp:189
NxVec3 operator/(NxReal f) const
Definition: NxVec3.cpp:255
NxVec3()
Definition: NxVec3.cpp:39
void setx(const NxReal &d)
Definition: NxVec3.cpp:59
NxReal z
Definition: NxVec3.h:80
void setPlusInfinity()
NxReal magnitude() const
Definition: NxVec3.cpp:194
void cross(const NxVec3 &left, const NxVec3 &right)
Definition: NxVec3.cpp:207
NxVec3 & operator*=(NxReal f)
Definition: NxVec3.cpp:277
void setMinusInfinity()
void sety(const NxReal &d)
Definition: NxVec3.cpp:64
bool operator!=(const NxVec3 &) const
Definition: NxVec3.cpp:79
NxVec3 & operator-=(const NxVec3 &v)
Definition: NxVec3.cpp:269
NxVec3 operator^(const NxVec3 &v) const
Definition: NxVec3.cpp:301
void multiplyAdd(NxReal s, const NxVec3 &a, const NxVec3 &b)
Definition: NxVec3.cpp:152
bool isFinite() const
NxVec3 & operator/=(NxReal f)
Definition: NxVec3.cpp:285
NxVec3 operator*(NxReal f) const
Definition: NxVec3.cpp:250
void rotate(NxReal angle, const NxVec3 &axe)
Definition: NxVec3.cpp:318
void add(const NxVec3 &a, const NxVec3 &b)
Definition: NxVec3.cpp:124
bool operator==(const NxVec3 &) const
Definition: NxVec3.cpp:74
bool operator<(const NxVec3 &) const
void setNegative()
Definition: NxVec3.cpp:98
void setz(const NxReal &d)
Definition: NxVec3.cpp:69
NxReal normalize()
Definition: NxVec3.cpp:159
bool equals(const NxVec3 &, NxReal epsilon) const
NxReal y
Definition: NxVec3.h:80
void zero()
Definition: NxVec3.cpp:119
void arrayMultiply(const NxVec3 &a, const NxVec3 &b)
Definition: NxVec3.cpp:138
const NxReal * get() const
Definition: NxVec3.cpp:49
NxReal distance(const NxVec3 &) const
Definition: NxVec3.cpp:199
void multiply(NxReal s, const NxVec3 &a)
Definition: NxVec3.cpp:145
NxReal dot(const NxVec3 &other) const
Definition: NxVec3.cpp:184
NxVec3 operator-() const
Definition: NxVec3.cpp:235
NxReal x
Definition: NxVec3.h:80
void set(const NxVec3 &)
Definition: NxVec3.cpp:84