00001 /* This file is part of Annchienta. 00002 * Copyright 2008 (C) Jasper Van der Jeugt 00003 * 00004 * Annchienta is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * Annchienta is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with Annchienta. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef ANNCHIENTA_VECTOR_H 00019 #define ANNCHIENTA_VECTOR_H 00020 00021 namespace Annchienta 00022 { 00023 00038 class Vector 00039 { 00040 public: 00041 00044 float x; 00047 float y; 00048 00053 Vector( float x, float y ); 00054 00059 Vector( const Vector &other ); 00060 ~Vector(); 00061 00062 #ifndef SWIG 00063 Vector &operator=(const Vector &other); 00064 #endif 00065 00066 Vector operator+(const Vector &other) const; 00067 Vector operator-(const Vector &other) const; 00068 00069 Vector operator*(const float &scalar) const; 00070 Vector operator/(const float &scalar) const; 00071 00072 Vector &operator+=(const Vector &other); 00073 Vector &operator-=(const Vector &other); 00074 00075 Vector &operator*=(const float &scalar); 00076 Vector &operator/=(const float &scalar); 00077 00080 float operator*(const Vector &other) const; 00081 00085 float length() const; 00086 00092 float lengthSquared() const; 00093 00100 float distance( const Vector &other ) const; 00101 00106 void normalize(); 00107 00114 void cap( const float &minimum, const float &maximum ); 00115 }; 00116 00117 }; 00118 00119 #endif