-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector3d.h
More file actions
39 lines (29 loc) · 1 KB
/
vector3d.h
File metadata and controls
39 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef VECTOR3D_H
#define VECTOR3D_H
#include <QVector3D>
class Vector3D {
public:
Vector3D() = default;
Vector3D(double x, double y, double z) : mx(x), my(y), mz(z) {}
explicit Vector3D(QVector3D const &v) : mx(v.x()), my(v.y()), mz(v.z()) {}
double mx = 0.0;
double my = 0.0;
double mz = 0.0;
inline double x() const { return mx; }
inline double y() const { return my; }
inline double z() const { return mz; }
QVector3D QVec();
double length() const;
double lengthSquared() const;
Vector3D normalized() const;
void normalize();
Vector3D operator-(Vector3D const &b) const;
Vector3D operator+(Vector3D const &b) const;
Vector3D operator*(double c) const;
Vector3D operator/(double c) const;
static double dotProduct(Vector3D const &a, Vector3D const &b);
static Vector3D crossProduct(Vector3D const &a, Vector3D const &b);
// Generate an arbitrary perpendicular vector
Vector3D orthognalVector() const;
};
#endif // VECTOR3D_H