-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.h
68 lines (52 loc) · 1.06 KB
/
utils.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
64
65
66
67
68
#ifndef UTILS
#define UTILS
// Extra functions that are needed
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class color{
public:
double r;
double g;
double b;
double a;
};
// radian to degree
float f(float a){
return a*3.14/180;
}
//http://stackoverflow.com/a/686376/164617
float r(float a, float b)
{
return ((b-a)*((float)rand()/RAND_MAX))+a;
}
// Some one should make this so that each rgb value is discrete
color randomColor(){
color c;
c.r=(float)rand()/(float)RAND_MAX;
c.b=(float)rand()/(float)RAND_MAX;
c.g= (float)rand()/(float)RAND_MAX;
return c;
}
double distance(double x1,double y1,double x2,double y2)
{
double dx,dy;
dx=abs(x2-x1);
dy=abs(y2-y1);
// cout<<dx<<" "<<dy<<endl;
return sqrt(dx*dx + dy*dy);
}
struct Image
{
unsigned long sizeX;
unsigned long sizeY;
GLubyte *data;
};
string convertInt(int number)
{
stringstream ss;//create a stringstream
ss << number;//add number to the stream
return ss.str();//return a string with the contents of the stream
}
#endif