-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
93 lines (76 loc) · 1.26 KB
/
util.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef _UTIL_H_
#define _UTIL_H_
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
//#include <SDL/SDL.h>
#include <SDL.h>
//#include "SDL/SDL_main.h"
#include "SDL_main.h"
#include <SDL/SDL_image.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#endif
#include <iostream>
using namespace std;
#define PI 3.1415926535
#define ROTSPEED 100.0
#define FORCE 500.0
#define RESISTANCE 0.5
class VECTOR {
public :
float x;
float y;
float z;
VECTOR ( )
{
x = 0.0;
y = 0.0;
z = 0.0;
}
VECTOR( float X , float Y , float Z )
{
x = X;
y = Y;
z = Z;
}
VECTOR operator+(VECTOR a)
{
return VECTOR(a.x + x, a.y + y, a.z + z);
}
VECTOR operator-(VECTOR a)
{
return VECTOR(x - a.x, y - a.y, z - a.z);
}
VECTOR operator*(float num)
{
return VECTOR(x * num, y * num, z * num);
}
VECTOR operator/(float num)
{
return VECTOR(x / num, y / num, z / num);
}
void set( float X , float Y , float Z )
{
x = X;
y = Y;
z = Z;
}
float magnitude( )
{
return sqrt ( this->x * this->x + this->y * this->y + this->z * this->z );
}
};
float vector_magnitude(VECTOR a);
class POLYGON {
public :
int num_vertices;
VECTOR* vertices;
VECTOR normal;
};
#endif