Last change
on this file since 9940 was
9110,
checked in by bensch, 18 years ago
|
orxonox/trunk: merged the Presentation back
|
File size:
1.5 KB
|
Line | |
---|
1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Christian Meyer |
---|
13 | co-programmer: Patrick Boenzli : Vector::scale() |
---|
14 | Vector::abs() |
---|
15 | |
---|
16 | Quaternion code borrowed from an Gamasutra article by Nick Bobick and Ken Shoemake |
---|
17 | |
---|
18 | 2005-06-02: Benjamin Grauer: speed up, and new Functionality to Vector (mostly inline now) |
---|
19 | */ |
---|
20 | |
---|
21 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MATH |
---|
22 | |
---|
23 | #include "vector.h" |
---|
24 | #ifdef DEBUG |
---|
25 | #include "debug.h" |
---|
26 | #else |
---|
27 | #include <stdio.h> |
---|
28 | #define PRINT(x) printf |
---|
29 | #endif |
---|
30 | |
---|
31 | |
---|
32 | ///////////// |
---|
33 | /* VECTORS */ |
---|
34 | ///////////// |
---|
35 | /** |
---|
36 | * returns the this-vector normalized to length 1.0 |
---|
37 | * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do. |
---|
38 | */ |
---|
39 | Vector Vector::getNormalized() const |
---|
40 | { |
---|
41 | float length = this->len(); |
---|
42 | if (unlikely(length == 0.0)) |
---|
43 | return *this; |
---|
44 | else |
---|
45 | return (*this / length); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * Vector is looking in the positive direction on all axes after this |
---|
50 | */ |
---|
51 | Vector Vector::abs() |
---|
52 | { |
---|
53 | Vector v(fabs(x), fabs(y), fabs(z)); |
---|
54 | return v; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * Outputs the values of the Vector |
---|
61 | */ |
---|
62 | void Vector::debug() const |
---|
63 | { |
---|
64 | PRINT(0)("x: %f; y: %f; z: %f", x, y, z); |
---|
65 | PRINT(0)(" lenght: %f", len()); |
---|
66 | PRINT(0)("\n"); |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.