All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector4.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: 4 tuple
18  * Author: Nate Koenig
19  * Date: 19 Aug 2008
20  */
21 
22 #ifndef _VECTOR4_HH_
23 #define _VECTOR4_HH_
24 
25 #include <iostream>
26 #include <fstream>
27 #include "math/Matrix4.hh"
28 
29 namespace gazebo
30 {
31  namespace math
32  {
35 
38  class Vector4
39  {
41  public: Vector4();
42 
48  public: Vector4(const double &_x, const double &_y, const double &_z,
49  const double &_w);
50 
53  public: Vector4(const Vector4 &_v);
54 
55 
57  public: virtual ~Vector4();
58 
62  public: double Distance(const Vector4 &_pt) const;
63 
65  public: double GetLength() const;
66 
69  public: double GetSquaredLength() const;
70 
72  public: void Normalize();
73 
79  public: void Set(double _x = 0, double _y = 0 , double _z = 0,
80  double _w = 0);
81 
85  public: Vector4 &operator =(const Vector4 &_v);
86 
89  public: Vector4 &operator =(double _value);
90 
94  public: Vector4 operator+(const Vector4 &_v) const;
95 
99  public: const Vector4 &operator+=(const Vector4 &_v);
100 
104  public: Vector4 operator-(const Vector4 &_v) const;
105 
109  public: const Vector4 &operator-=(const Vector4 &_v);
110 
116  public: const Vector4 operator/(const Vector4 &_v) const;
117 
123  public: const Vector4 &operator/=(const Vector4 &_v);
124 
130  public: const Vector4 operator/(double _v) const;
131 
135  public: const Vector4 &operator/=(double _v);
136 
142  public: const Vector4 operator*(const Vector4 &_pt) const;
143 
147  public: const Vector4 operator*(const Matrix4 &_m) const;
148 
154  public: const Vector4 &operator*=(const Vector4 &_pt);
155 
159  public: const Vector4 operator*(double _v) const;
160 
164  public: const Vector4 &operator*=(double _v);
165 
170  public: bool operator ==(const Vector4 &_pt) const;
171 
176  public: bool operator!=(const Vector4 &_pt) const;
177 
180  public: bool IsFinite() const;
181 
184  public: double operator[](unsigned int _index) const;
185 
187  public: double x;
188 
190  public: double y;
191 
193  public: double z;
194 
196  public: double w;
197 
202  public: friend std::ostream &operator<<(std::ostream &_out,
203  const gazebo::math::Vector4 &_pt)
204  {
205  _out << _pt.x << " " << _pt.y << " " << _pt.z << " " << _pt.w;
206  return _out;
207  }
208 
213  public: friend std::istream &operator >> (std::istream &_in,
215  {
216  // Skip white spaces
217  _in.setf(std::ios_base::skipws);
218  _in >> _pt.x >> _pt.y >> _pt.z >> _pt.w;
219  return _in;
220  }
221  };
223  }
224 }
225 #endif
226 
227 
228