-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMyMath.h
63 lines (47 loc) · 1.52 KB
/
MyMath.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef _MYMATH_H_PROJECT_TRANSPORT
#define _MYMATH_H_PROJECT_TRANSPORT
#include <cmath>
#include <iostream>
#include <fstream>
#include <complex>
//using namespace::std;
//Simple, geometric three-vector. Nothing fancy!
template <class T>
class vec3 {
public:
T x, y, z;
//Constructors.
vec3();
vec3(T a, T b, T c);
//Operators - vec3 typed.
vec3 & operator=(const vec3 &);
vec3 operator+(const vec3 &);
vec3 & operator+=(const vec3 &);
vec3 operator-(const vec3 &);
vec3 & operator-=(const vec3 &);
bool operator==(const vec3 &);
//Operators - T typed.
/*
vec3 operator*(const T);
vec3 & operator*=(const T);
vec3 operator/(const T);
vec3 & operator/=(const T);
*/
vec3 operator*(const T &);
vec3 & operator*=(const T &);
vec3 operator/(const T &);
vec3 & operator/=(const T &);
//Other.
// ---> normalization operator.
vec3 unit();
// ---> (pythagorean) length of vector.
T length();
// ---> (pythagorean) distance between vectors.
T distance(const vec3 &);
// ---> overloaded stream operator.
template<class Y> friend std::ostream & operator << (std::ostream &, const vec3<Y> &);
};
//This is a function for rotation unit vectors in some plane. It requires angles to describe the plane of rotation, angle of rotation.
// It also requires a unit vector with which to rotate the plane about.
vec3<double> rotate_unit_vector_in_plane(const vec3<double> &A, const double &theta, const double &R);
#endif