annotate src/vector.inl @ 24:13091c00d7ca
- moved create_face_buffer to Scene::get_face_buffer and did a few reorganizations.
- starting work on the kdtree creation
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Sat, 14 Aug 2010 03:02:52 +0100 |
parents |
|
children |
6a30f27fa1e6 |
rev |
line source |
nuclear@23
|
1 #include <math.h>
|
nuclear@23
|
2
|
nuclear@23
|
3 inline float Vector3::length()
|
nuclear@23
|
4 {
|
nuclear@23
|
5 return sqrt(x * x + y * y + z * z);
|
nuclear@23
|
6 }
|
nuclear@23
|
7
|
nuclear@23
|
8 inline float Vector3::lengthsq()
|
nuclear@23
|
9 {
|
nuclear@23
|
10 return x * x + y * y + z * z;
|
nuclear@23
|
11 }
|
nuclear@23
|
12
|
nuclear@23
|
13 inline Vector3 operator +(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
14 {
|
nuclear@23
|
15 return Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
|
nuclear@23
|
16 }
|
nuclear@23
|
17
|
nuclear@23
|
18 inline Vector3 operator -(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
19 {
|
nuclear@23
|
20 return Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
|
nuclear@23
|
21 }
|
nuclear@23
|
22
|
nuclear@23
|
23 inline Vector3 operator *(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
24 {
|
nuclear@23
|
25 return Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
|
nuclear@23
|
26 }
|
nuclear@23
|
27
|
nuclear@23
|
28 inline Vector3 operator /(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
29 {
|
nuclear@23
|
30 return Vector3(a.x / b.x, a.y / b.y, a.z / b.z);
|
nuclear@23
|
31 }
|
nuclear@23
|
32
|
nuclear@23
|
33
|
nuclear@23
|
34 inline Vector3 operator -(const Vector3 &vec)
|
nuclear@23
|
35 {
|
nuclear@23
|
36 return Vector3(-vec.x, -vec.y, -vec.z);
|
nuclear@23
|
37 }
|
nuclear@23
|
38
|
nuclear@23
|
39 inline Vector3 operator *(const Vector3 &vec, float s)
|
nuclear@23
|
40 {
|
nuclear@23
|
41 return Vector3(vec.x * s, vec.y * s, vec.z * s);
|
nuclear@23
|
42 }
|
nuclear@23
|
43
|
nuclear@23
|
44
|
nuclear@23
|
45 inline float dot(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
46 {
|
nuclear@23
|
47 return a.x * b.x + a.y * b.y + a.z * b.z;
|
nuclear@23
|
48 }
|
nuclear@23
|
49
|
nuclear@23
|
50 inline Vector3 cross(const Vector3 &a, const Vector3 &b)
|
nuclear@23
|
51 {
|
nuclear@23
|
52 return Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
|
nuclear@23
|
53 }
|