-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vector3.h
38 lines (29 loc) · 818 Bytes
/
Vector3.h
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
//
// Created by James Lemkin on 12/5/19.
//
#ifndef HW5_POINT_H
#define HW5_POINT_H
#include <ostream>
#include <cmath>
class Vector3 {
public:
double x, y, z;
friend std::ostream &operator<<(std::ostream &os, const Vector3 &vector3) {
os << "(" << vector3.x << "," << vector3.y << "," << vector3.z << ")";
return os;
}
Vector3(double x, double y, double z) : x(x), y(y), z(z) {}
Vector3();
Vector3 operator-(Vector3 v2) const;
Vector3 operator*(double s) const;
Vector3 operator/(double s) const;
Vector3 operator-() const;
Vector3 operator+(Vector3 v2) const;
void operator+=(Vector3 v2);
Vector3 cross(Vector3 v2) const;
double dot(Vector3 v2) const;
double angleWith(Vector3 v2) const;
Vector3 normalize() const;
double magnitude() const;
};
#endif //HW5_POINT_H