Vector3.hh
00001 /* 00002 * Gazebo - Outdoor Multi-Robot Simulator 00003 * Copyright (C) 2003 00004 * Nate Koenig & Andrew Howard 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 /* Desc: The world; all models are collected here 00022 * Author: Nate Koenig 00023 * Date: 3 Apr 2007 00024 * SVN: $Id: Vector3.hh 156 2007-11-26 20:26:57Z natepak $ 00025 */ 00026 00027 #ifndef VECTOR3_HH 00028 #define VECTOR3_HH 00029 00030 #include <iostream> 00031 #include <fstream> 00032 00033 namespace gazebo 00034 { 00038 00040 class Vector3 00041 { 00043 public: Vector3(); 00044 00046 public: Vector3( const double &x, const double &y, const double &z ); 00047 00049 public: Vector3( const Vector3 &pt ); 00050 00052 public: virtual ~Vector3(); 00053 00055 public: double Distance( const Vector3 &pt ) const; 00056 00058 public: double GetLength() const; 00059 00061 public: double GetSquaredLength() const; 00062 00064 public: void Normalize(); 00065 00067 public: void Set(double x = 0, double y =0 , double z = 0); 00068 00070 public: Vector3 GetCrossProd(const Vector3 &pt) const; 00071 00073 public: Vector3 GetPerpendicular() const; 00074 00076 public: const Vector3 &operator=( const Vector3 &pt ); 00077 00079 public: const Vector3 &operator=( double value ); 00080 00082 public: Vector3 operator+( const Vector3 &pt ) const; 00083 00085 public: const Vector3 &operator+=( const Vector3 &pt ); 00086 00088 public: Vector3 operator-( const Vector3 &pt ) const; 00089 00091 public: const Vector3 &operator-=( const Vector3 &pt ); 00092 00094 public: const Vector3 operator/( const Vector3 &pt ) const; 00095 00097 public: const Vector3 &operator/=( const Vector3 &pt ); 00098 00100 public: const Vector3 operator/( double v ) const; 00101 00103 public: const Vector3 &operator/=( double v ); 00104 00106 public: const Vector3 operator*( const Vector3 &pt ) const; 00107 00109 public: const Vector3 &operator*=( const Vector3 &pt ); 00110 00112 public: const Vector3 operator*( double v ) const; 00113 00115 public: const Vector3 &operator*=( double v ); 00116 00118 public: bool operator==( const Vector3 &pt ) const; 00119 00121 public: bool operator!=( const Vector3 &pt ) const; 00122 00124 public: bool IsFinite() const; 00125 00127 public: double operator[](unsigned int index) const; 00128 00130 public: double x; 00131 00133 public: double y; 00134 00136 public: double z; 00137 00142 public: friend std::ostream &operator<<( std::ostream &out, const gazebo::Vector3 &pt ) 00143 { 00144 out << pt.x << " " << pt.y << " " << pt.z; 00145 00146 return out; 00147 } 00148 00149 }; 00150 00152 } 00153 00154 #endif