XX CMake Package
Loading...
Searching...
No Matches
XXLinalgVector3.h
Go to the documentation of this file.
1#ifndef XXLinalgVector3H
2#define XXLinalgVector3H
3
4#include "XXMathExportDef.h"
5
6#include <iostream>
7
8#include <QDebug>
9#include <QTextStream>
10
11#include "XXLinalgSpherical.h"
12
13namespace XX
14{
15 namespace Linalg
16 {
19
21 {
22 enum Index
23 {
24 X = 0,
25 Y = 1,
26 Z = 2
27 };
28
29 public:
30 Vector3(const double& x = 0.0, const double& y = 0.0, const double& z = 0.0);
31
32 public:
33 bool operator==(const Vector3& other) const;
34 bool operator<(const Vector3& other) const;
35
36 Vector3 operator+(const Vector3& other) const;
37 Vector3& operator+=(const Vector3& other);
38
39 const double& operator[](const int index) const;
40 double& operator[](const int index);
41
42 public:
43 const double& getX() const;
44 const double& getY() const;
45 const double& getZ() const;
46
47 // for 2d version see MathGeneral.h
48 static Vector3 fromSpherical(const Spherical& spherical, const bool fromDegree = true);
49 Spherical toSpherical(const bool toDegree = true) const;
50
51 double length() const;
52 Vector3 norm() const;
53
54 double dot(const Vector3& other) const;
55 double dotAngle(const Vector3& other, const bool toDegree = true) const;
56
57 Vector3 cross(const Vector3& other) const;
58 double crossAngle(const Vector3& other, const bool toDegree = true) const;
59
60 private:
61 friend XXMATH_DECLSPEC std::ostream& operator<<(std::ostream& out, const Vector3& vector);
62 friend XXMATH_DECLSPEC QDebug operator<<(QDebug stream, const Vector3& vector);
63 friend XXMATH_DECLSPEC QTextStream& operator>>(QTextStream& stream, Vector3& vector);
64 friend XXMATH_DECLSPEC QTextStream& operator<<(QTextStream& stream, const Vector3& vector);
65
66 private:
67 union
68 {
69 struct
70 {
71 double x;
72 double y;
73 double z;
74 };
75 double data[3];
76 };
77 };
78
84
85 XXMATH_DECLSPEC std::ostream& operator<<(std::ostream& out, const Vector3& vector);
86 XXMATH_DECLSPEC QDebug operator<<(QDebug stream, const Vector3& vector);
87 XXMATH_DECLSPEC QTextStream& operator>>(QTextStream& stream, Vector3& vector);
88 XXMATH_DECLSPEC QTextStream& operator<<(QTextStream& stream, const Vector3& vector);
89
91
92 } // namespace Linalg
93} // namespace XX
94
95#endif // NOT XXLinalgVector3H
#define XXMATH_DECLSPEC
Definition XXMathExportDef.h:17
Spherical coordinates, used to represent points in 3D space.
Definition XXLinalgSpherical.h:18
3D vector, used to represent points or directions in 3D space.
Definition XXLinalgVector3.h:21
Vector3 norm() const
double x
Definition XXLinalgVector3.h:71
const double & getZ() const
friend std::ostream & operator<<(std::ostream &out, const Vector3 &vector)
double z
Definition XXLinalgVector3.h:73
Vector3 cross(const Vector3 &other) const
friend QTextStream & operator<<(QTextStream &stream, const Vector3 &vector)
double length() const
Vector3 operator+(const Vector3 &other) const
double data[3]
Definition XXLinalgVector3.h:75
static Vector3 fromSpherical(const Spherical &spherical, const bool fromDegree=true)
double dotAngle(const Vector3 &other, const bool toDegree=true) const
double crossAngle(const Vector3 &other, const bool toDegree=true) const
const double & getY() const
Spherical toSpherical(const bool toDegree=true) const
friend QDebug operator<<(QDebug stream, const Vector3 &vector)
friend QTextStream & operator>>(QTextStream &stream, Vector3 &vector)
double & operator[](const int index)
const double & getX() const
bool operator<(const Vector3 &other) const
bool operator==(const Vector3 &other) const
const double & operator[](const int index) const
Vector3 & operator+=(const Vector3 &other)
Vector3(const double &x=0.0, const double &y=0.0, const double &z=0.0)
double dot(const Vector3 &other) const
double y
Definition XXLinalgVector3.h:72
QDebug operator<<(QDebug stream, const Matrix &matrix)
QTextStream & operator>>(QTextStream &stream, Matrix &matrix)
Definition XXLinalg.h:10
Definition XXPopulatedAbstract.h:11