clray
view src/vector.inl @ 51:9c0867942612
changed the binary target to clray
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 02 Sep 2010 01:41:51 +0100 |
parents | |
children | 6a30f27fa1e6 |
line source
1 #include <math.h>
3 inline float Vector3::length()
4 {
5 return sqrt(x * x + y * y + z * z);
6 }
8 inline float Vector3::lengthsq()
9 {
10 return x * x + y * y + z * z;
11 }
13 inline Vector3 operator +(const Vector3 &a, const Vector3 &b)
14 {
15 return Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
16 }
18 inline Vector3 operator -(const Vector3 &a, const Vector3 &b)
19 {
20 return Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
21 }
23 inline Vector3 operator *(const Vector3 &a, const Vector3 &b)
24 {
25 return Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
26 }
28 inline Vector3 operator /(const Vector3 &a, const Vector3 &b)
29 {
30 return Vector3(a.x / b.x, a.y / b.y, a.z / b.z);
31 }
34 inline Vector3 operator -(const Vector3 &vec)
35 {
36 return Vector3(-vec.x, -vec.y, -vec.z);
37 }
39 inline Vector3 operator *(const Vector3 &vec, float s)
40 {
41 return Vector3(vec.x * s, vec.y * s, vec.z * s);
42 }
45 inline float dot(const Vector3 &a, const Vector3 &b)
46 {
47 return a.x * b.x + a.y * b.y + a.z * b.z;
48 }
50 inline Vector3 cross(const Vector3 &a, const Vector3 &b)
51 {
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);
53 }