Last change
on this file since 7606 was
6617,
checked in by bensch, 19 years ago
|
trunk: split Rotation/Line/Quaternion/Plane(Rectangle) into seperate files
|
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 | using namespace std; |
---|
32 | |
---|
33 | ///////////// |
---|
34 | /* VECTORS */ |
---|
35 | ///////////// |
---|
36 | /** |
---|
37 | * returns the this-vector normalized to length 1.0 |
---|
38 | * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do. |
---|
39 | */ |
---|
40 | Vector Vector::getNormalized() const |
---|
41 | { |
---|
42 | float l = this->len(); |
---|
43 | if(unlikely(l == 1.0 || l == 0.0)) |
---|
44 | return *this; |
---|
45 | else |
---|
46 | return (*this / l); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * Vector is looking in the positive direction on all axes after this |
---|
51 | */ |
---|
52 | Vector Vector::abs() |
---|
53 | { |
---|
54 | Vector v(fabs(x), fabs(y), fabs(z)); |
---|
55 | return v; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | /** |
---|
61 | * Outputs the values of the Vector |
---|
62 | */ |
---|
63 | void Vector::debug() const |
---|
64 | { |
---|
65 | PRINT(0)("x: %f; y: %f; z: %f", x, y, z); |
---|
66 | PRINT(0)(" lenght: %f", len()); |
---|
67 | PRINT(0)("\n"); |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.