Last change
on this file since 10746 was
9110,
checked in by bensch, 18 years ago
|
orxonox/trunk: merged the Presentation back
|
File size:
1.5 KB
|
Rev | Line | |
---|
[4578] | 1 | /* |
---|
[2043] | 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: |
---|
[4578] | 12 | main-programmer: Christian Meyer |
---|
[2551] | 13 | co-programmer: Patrick Boenzli : Vector::scale() |
---|
| 14 | Vector::abs() |
---|
[4578] | 15 | |
---|
[2190] | 16 | Quaternion code borrowed from an Gamasutra article by Nick Bobick and Ken Shoemake |
---|
[5420] | 17 | |
---|
| 18 | 2005-06-02: Benjamin Grauer: speed up, and new Functionality to Vector (mostly inline now) |
---|
[2043] | 19 | */ |
---|
| 20 | |
---|
[3590] | 21 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MATH |
---|
[2043] | 22 | |
---|
| 23 | #include "vector.h" |
---|
[5662] | 24 | #ifdef DEBUG |
---|
[5672] | 25 | #include "debug.h" |
---|
[5662] | 26 | #else |
---|
[5672] | 27 | #include <stdio.h> |
---|
| 28 | #define PRINT(x) printf |
---|
[5662] | 29 | #endif |
---|
[2043] | 30 | |
---|
| 31 | |
---|
[4477] | 32 | ///////////// |
---|
| 33 | /* VECTORS */ |
---|
| 34 | ///////////// |
---|
[2043] | 35 | /** |
---|
[4836] | 36 | * returns the this-vector normalized to length 1.0 |
---|
[4966] | 37 | * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do. |
---|
[5420] | 38 | */ |
---|
[4372] | 39 | Vector Vector::getNormalized() const |
---|
[2551] | 40 | { |
---|
[9110] | 41 | float length = this->len(); |
---|
| 42 | if (unlikely(length == 0.0)) |
---|
[4966] | 43 | return *this; |
---|
| 44 | else |
---|
[9110] | 45 | return (*this / length); |
---|
[2551] | 46 | } |
---|
| 47 | |
---|
[3449] | 48 | /** |
---|
[4836] | 49 | * Vector is looking in the positive direction on all axes after this |
---|
[4477] | 50 | */ |
---|
[4578] | 51 | Vector Vector::abs() |
---|
[4477] | 52 | { |
---|
| 53 | Vector v(fabs(x), fabs(y), fabs(z)); |
---|
| 54 | return v; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | /** |
---|
[4836] | 60 | * Outputs the values of the Vector |
---|
[5420] | 61 | */ |
---|
[4746] | 62 | void Vector::debug() const |
---|
[3541] | 63 | { |
---|
| 64 | PRINT(0)("x: %f; y: %f; z: %f", x, y, z); |
---|
[4987] | 65 | PRINT(0)(" lenght: %f", len()); |
---|
[3541] | 66 | PRINT(0)("\n"); |
---|
| 67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.