-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcollision.h
60 lines (44 loc) · 1023 Bytes
/
collision.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
/*
** collision.h
**
** Some nice vector functions and stuff... for PixelMachine
** by SuperJer
**
** Email = [email protected]
** Web = http://www.superjer.com/
**
** You can do whatever you like with this code, I don't care,
** just please recognize me as the original author. :)
**
*/
#ifndef __COLLISION_H__
#define __COLLISION_H__
#include <math.h>
#define NO_COLLISION -1.0
struct V
{
double x;
double y;
double z;
};
struct COLOR
{
double r;
double g;
double b;
double a;
};
struct SPHERE
{
V center;
double radius;
COLOR color;
};
V &add( V &out, const V &a, const V &b );
V &subtract( V &out, const V &a, const V &b );
V &cross( V &out, const V &a, const V &b );
V &scale( V &out, double n );
V &normalize( V &out, double n );
V &mirror( V &out, const V &in, const V &mirror );
void CollideRaySphere( double &t, const V &o, const V &v, const V &p, const double &r );
#endif //__COLLISION_H__