-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMath_Test.cc
87 lines (59 loc) · 2.65 KB
/
Math_Test.cc
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <cmath>
#include <complex>
#include <random>
#include <fstream>
#include "./MyMath.h"
//This program tests out the rotate_about_a_unit_vector_in_a_plane function. Draws some loops in various points. Looks for nans, infs, and garbage.
int main(int argc, char **argv){
std::mt19937 random_engine;
std::uniform_real_distribution<> random_distribution(0.0, 1.0);
std::random_device rd; //Generates a hardware-generated random seed.
random_engine.seed( rd() );
// Call like: random_distribution(random_engine);
vec3<double> test1(0.0,0.0,-1.0);
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, 0.5*M_PI, 0.5*M_PI));
std::cout << "The first vector was " << test1 << std::endl;
std::cout << " and the second is " << test2 << std::endl;
std::fstream Filep;
Filep.open("/tmp/mathtest", std::ios::out );
if(!Filep.good()){
std::cout << "Unable to open profile output file. Exiting." << std::endl;
return -1;
}
Filep << "# x y z " << std::endl;
for(size_t j=0; j<10000; ++j){
vec3<double> test1( 1.2, 2.3, 3.4 );
test1.unit();
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, 1.234, random_distribution(random_engine)*2.0*M_PI));
Filep << test2 << std::endl;
}
for(size_t j=0; j<10000; ++j){
vec3<double> test1( 1.2, 2.3, 3.4 );
test1.unit();
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, 1.75, random_distribution(random_engine)*2.0*M_PI));
Filep << test2 << std::endl;
}
for(size_t j=0; j<10000; ++j){
vec3<double> test1( 1.2, 2.3, 3.4 );
test1.unit();
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, 2.15, random_distribution(random_engine)*2.0*M_PI));
Filep << test2 << std::endl;
}
for(size_t j=0; j<10000; ++j){
vec3<double> test1( -4.2, -0.3, 2.4 );
test1.unit();
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, -1.234, random_distribution(random_engine)*2.0*M_PI));
Filep << test2 << std::endl;
}
for(size_t j=0; j<10000; ++j){
vec3<double> test1( 1.2, 2.3, 3.4 );
test1.unit();
// vec3<double> test2 = (rotate_unit_vector_in_plane(test1, random_distribution(random_engine)*M_PI, random_distribution(random_engine)*2.0*M_PI));
// vec3<double> test2 = (rotate_unit_vector_in_plane(test1, random_distribution(random_engine)*M_PI, 1.23456));
vec3<double> test2 = (rotate_unit_vector_in_plane(test1, 2.0*random_distribution(random_engine)*M_PI, 1.23456));
Filep << test2 << std::endl;
}
Filep.close();
return 0;
}