Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/spaceshipcontrol/src/lib/math/vector2D.cc @ 7050

Last change on this file since 7050 was 6615, checked in by bensch, 19 years ago

orxonox/trunk: added vector2D, a 2D-version of the 3D-vector

File size: 1.4 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: Benjamin Grauer
13   co-programmer: Patrick Boenzli : Vector2D::scale()
14                                    Vector2D::abs()
15
16   Benjamin Grauer: port to Vector2D
17*/
18
19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MATH
20
21#include "vector2D.h"
22#ifdef DEBUG
23  #include "debug.h"
24#else
25  #include <stdio.h>
26  #define PRINT(x) printf
27#endif
28
29using namespace std;
30
31/////////////
32/* VECTORS */
33/////////////
34/**
35 *  returns the this-vector normalized to length 1.0
36 * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do.
37 */
38Vector2D Vector2D::getNormalized() const
39{
40  float l = this->len();
41  if(unlikely(l == 1.0 || l == 0.0))
42    return *this;
43  else
44    return (*this / l);
45}
46
47/**
48 *  Vector2D is looking in the positive direction on all axes after this
49*/
50Vector2D Vector2D::abs()
51{
52  Vector2D v(fabs(x), fabs(y));
53  return v;
54}
55
56
57
58/**
59 *  Outputs the values of the Vector2D
60 */
61void Vector2D::debug() const
62{
63  PRINT(0)("x: %f; y: %f", x, y);
64  PRINT(0)(" lenght: %f", len());
65  PRINT(0)("\n");
66}
Note: See TracBrowser for help on using the repository browser.