Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/math/vector.cc @ 6659

Last change on this file since 6659 was 6617, checked in by bensch, 19 years ago

trunk: split Rotation/Line/Quaternion/Plane(Rectangle) into seperate files

File size: 1.5 KB
RevLine 
[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
31using namespace std;
32
[4477]33/////////////
34/* VECTORS */
35/////////////
[2043]36/**
[4836]37 *  returns the this-vector normalized to length 1.0
[4966]38 * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do.
[5420]39 */
[4372]40Vector Vector::getNormalized() const
[2551]41{
[4966]42  float l = this->len();
43  if(unlikely(l == 1.0 || l == 0.0))
44    return *this;
45  else
46    return (*this / l);
[2551]47}
48
[3449]49/**
[4836]50 *  Vector is looking in the positive direction on all axes after this
[4477]51*/
[4578]52Vector Vector::abs()
[4477]53{
54  Vector v(fabs(x), fabs(y), fabs(z));
55  return v;
56}
57
58
59
60/**
[4836]61 *  Outputs the values of the Vector
[5420]62 */
[4746]63void Vector::debug() const
[3541]64{
65  PRINT(0)("x: %f; y: %f; z: %f", x, y, z);
[4987]66  PRINT(0)(" lenght: %f", len());
[3541]67  PRINT(0)("\n");
68}
Note: See TracBrowser for help on using the repository browser.