Mercurial > fife-parpg
comparison engine/core/util/structures/utilstructures.i @ 645:291ba2946c73
* Added the ability to normalize a 2D and 3D point.
* You can now rotate a 2D point around the origin or a specific point.
* Modified the shooter demo to use the new point functionality.
* Removed the fife_math extension.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 12 Oct 2010 18:58:47 +0000 |
parents | c0c3f64bfc2d |
children |
comparison
equal
deleted
inserted
replaced
644:b84dbc4665b0 | 645:291ba2946c73 |
---|---|
1 /*************************************************************************** | 1 /*************************************************************************** |
2 * Copyright (C) 2005-2008 by the FIFE team * | 2 * Copyright (C) 2005-2010 by the FIFE team * |
3 * http://www.fifengine.de * | 3 * http://www.fifengine.net * |
4 * This file is part of FIFE. * | 4 * This file is part of FIFE. * |
5 * * | 5 * * |
6 * FIFE is free software; you can redistribute it and/or * | 6 * FIFE is free software; you can redistribute it and/or * |
7 * modify it under the terms of the GNU Lesser General Public * | 7 * modify it under the terms of the GNU Lesser General Public * |
8 * License as published by the Free Software Foundation; either * | 8 * License as published by the Free Software Foundation; either * |
29 template <typename T> class PointType2D { | 29 template <typename T> class PointType2D { |
30 public: | 30 public: |
31 T x; | 31 T x; |
32 T y; | 32 T y; |
33 explicit PointType2D(T _x = 0, T _y = 0); | 33 explicit PointType2D(T _x = 0, T _y = 0); |
34 PointType2D(const PointType2D<T>& rhs); | |
34 PointType2D<T> operator+(const PointType2D<T>& p) const; | 35 PointType2D<T> operator+(const PointType2D<T>& p) const; |
35 PointType2D<T> operator-(const PointType2D<T>& p) const; | 36 PointType2D<T> operator-(const PointType2D<T>& p) const; |
36 PointType2D<T>& operator+=(const PointType2D<T>& p); | 37 PointType2D<T>& operator+=(const PointType2D<T>& p); |
37 PointType2D<T>& operator-=(const PointType2D<T>& p); | 38 PointType2D<T>& operator-=(const PointType2D<T>& p); |
38 PointType2D<T> operator*(const T& i) const; | 39 PointType2D<T> operator*(const T& i) const; |
39 PointType2D<T> operator/(const T& i) const; | 40 PointType2D<T> operator/(const T& i) const; |
40 bool operator==(const PointType2D<T>& p) const; | 41 bool operator==(const PointType2D<T>& p) const; |
41 bool operator!=(const PointType2D<T>& p) const; | 42 bool operator!=(const PointType2D<T>& p) const; |
42 T length() const; | 43 T length() const; |
44 void normalize(); | |
45 void rotate(T angle); | |
46 void rotate(const PointType2D<T>& origin, T angle); | |
43 }; | 47 }; |
44 | 48 |
45 template<typename T> | 49 template<typename T> |
46 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p); | 50 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p); |
47 | 51 |
58 public: | 62 public: |
59 T x; | 63 T x; |
60 T y; | 64 T y; |
61 T z; | 65 T z; |
62 explicit PointType3D(T _x = 0, T _y = 0, T _z = 0); | 66 explicit PointType3D(T _x = 0, T _y = 0, T _z = 0); |
67 PointType3D(const PointType3D<T>& rhs); | |
63 PointType3D<T> operator+(const PointType3D<T>& p) const; | 68 PointType3D<T> operator+(const PointType3D<T>& p) const; |
64 PointType3D<T> operator-(const PointType3D<T>& p) const; | 69 PointType3D<T> operator-(const PointType3D<T>& p) const; |
65 PointType3D<T>& operator+=(const PointType3D<T>& p); | 70 PointType3D<T>& operator+=(const PointType3D<T>& p); |
66 PointType3D<T>& operator-=(const PointType3D<T>& p); | 71 PointType3D<T>& operator-=(const PointType3D<T>& p); |
67 PointType3D<T> operator*(const T& i) const; | 72 PointType3D<T> operator*(const T& i) const; |
68 PointType3D<T> operator/(const T& i) const; | 73 PointType3D<T> operator/(const T& i) const; |
69 bool operator==(const PointType3D<T>& p) const; | 74 bool operator==(const PointType3D<T>& p) const; |
70 bool operator!=(const PointType3D<T>& p) const; | 75 bool operator!=(const PointType3D<T>& p) const; |
71 T length() const; | 76 T length() const; |
77 void normalize(); | |
72 }; | 78 }; |
73 | 79 |
74 template<typename T> | 80 template<typename T> |
75 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p); | 81 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p); |
76 | 82 |