Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * vector.h - Column Vector 00004 * 00005 * Created: Wed April 02 14:03:32 2008 00006 * Copyright 2008 Daniel Beck 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __GEOMETRY_VECTOR_H_ 00025 #define __GEOMETRY_VECTOR_H_ 00026 00027 #include <ostream> 00028 00029 namespace fawkes { 00030 00031 class Vector 00032 { 00033 public: 00034 Vector(unsigned int size = 3, float* elems = 0, bool manage_memory = true); 00035 Vector(const Vector& v); 00036 virtual ~Vector(); 00037 00038 unsigned int size() const; 00039 void set_size(unsigned int size); 00040 00041 float* data_ptr() { return m_data; } 00042 const float* data_ptr() const { return m_data; } 00043 00044 float get(unsigned int d) const; 00045 float& get(unsigned int d); 00046 void set(unsigned int d, float v); 00047 00048 float x() const; 00049 float& x(); 00050 void x(float x); 00051 00052 float y() const; 00053 float& y(); 00054 void y(float y); 00055 00056 float z() const; 00057 float& z(); 00058 void z(float z); 00059 00060 float operator[](unsigned int d) const; 00061 float& operator[](unsigned int d); 00062 00063 Vector operator*(const float& f) const; 00064 Vector& operator*=(const float& f); 00065 Vector operator/(const float& f) const; 00066 Vector& operator/=(const float& f); 00067 00068 float operator*(const Vector& v) const; 00069 00070 Vector operator+(const Vector& v) const; 00071 Vector& operator+=(const Vector& v); 00072 Vector operator-(const Vector& v) const; 00073 Vector& operator-=(const Vector& v); 00074 Vector& operator=(const Vector& v); 00075 00076 bool operator==(const Vector& v); 00077 00078 void print_info(const char* name = 0) const; 00079 00080 friend std::ostream& operator<<(std::ostream& stream, const Vector &v); 00081 00082 private: 00083 unsigned int m_size; 00084 float* m_data; 00085 bool m_manage_memory; 00086 }; 00087 00088 } // end namespace fawkes 00089 00090 #endif /* __GEOMETRY_VECTOR_H_ */