aboutsummaryrefslogtreecommitdiff
path: root/src/vector.hpp
blob: 20e8210c1f572f8b3ea5e2fe21689efbf4f8e913 (plain)
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
#ifndef VECTOR_H
#define VECTOR_H

#include <iostream>

class Vec3d {
    public:
        Vec3d();
        Vec3d(double x, double y, double z);

        void set(double x, double y, double z);
        void normalize();

        double length() const;
        double dot(const Vec3d &vec) const;

        Vec3d cross(const Vec3d &vec) const;

        // Operators
        Vec3d operator+(const Vec3d &vec) const;
        Vec3d& operator+=(const Vec3d &vec);
        Vec3d operator-(const Vec3d &vec) const;
        Vec3d operator-() const;
        Vec3d operator*(double) const;
        Vec3d operator*(const Vec3d &vec) const;
        Vec3d operator/(double) const;

        friend std::ostream& operator<<(std::ostream& os, const Vec3d &v);

        double m_x, m_y, m_z;
};

#endif