-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
37 lines (26 loc) · 840 Bytes
/
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
#ifndef UTILS_H
#define UTILS_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include <string.h>
#include <omp.h>
#include <GLFW/glfw3.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "deltatime.h"
/* Rotate (x, y) around (0, 0) by r radians */
#define rotate_x(x, y, r) (x * cos(r) - y * sin(r))
#define rotate_y(x, y, r) (x * sin(r) + y * cos(r))
/* Extract r bits from b starting at s: b[s, s + r) */
#define bitrange(b, s, r) ((b >> s) & ((1 << r) - 1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define PI (double)3.141592654
#define rand_float(a, b) (a) + (rand() / (float)RAND_MAX) * ((b) - (a))
#define msec(sec) (double)((sec) * 1.0e+3)
#define usec(sec) (double)((sec) * 1.0e+6)
double walltime(void);
#endif /* UTILS_H */