Vector4.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
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 "gazebo/math/Matrix4.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace math
33  {
36 
40  {
42  public: Vector4();
43 
49  public: Vector4(const double &_x, const double &_y, const double &_z,
50  const double &_w);
51 
54  public: Vector4(const Vector4 &_v);
55 
56 
58  public: virtual ~Vector4();
59 
63  public: double Distance(const Vector4 &_pt) const;
64 
66  public: double GetLength() const;
67 
70  public: double GetSquaredLength() const;
71 
73  public: void Normalize();
74 
80  public: void Set(double _x = 0, double _y = 0 , double _z = 0,
81  double _w = 0);
82 
86  public: Vector4 &operator =(const Vector4 &_v);
87 
90  public: Vector4 &operator =(double _value);
91 
95  public: Vector4 operator+(const Vector4 &_v) const;
96 
100  public: const Vector4 &operator+=(const Vector4 &_v);
101 
105  public: Vector4 operator-(const Vector4 &_v) const;
106 
110  public: const Vector4 &operator-=(const Vector4 &_v);
111 
117  public: const Vector4 operator/(const Vector4 &_v) const;
118 
124  public: const Vector4 &operator/=(const Vector4 &_v);
125 
131  public: const Vector4 operator/(double _v) const;
132 
136  public: const Vector4 &operator/=(double _v);
137 
143  public: const Vector4 operator*(const Vector4 &_pt) const;
144 
148  public: const Vector4 operator*(const Matrix4 &_m) const;
149 
155  public: const Vector4 &operator*=(const Vector4 &_pt);
156 
160  public: const Vector4 operator*(double _v) const;
161 
165  public: const Vector4 &operator*=(double _v);
166 
171  public: bool operator ==(const Vector4 &_pt) const;
172 
177  public: bool operator!=(const Vector4 &_pt) const;
178 
181  public: bool IsFinite() const;
182 
185  public: double operator[](unsigned int _index) const;
186 
188  public: double x;
189 
191  public: double y;
192 
194  public: double z;
195 
197  public: double w;
198 
203  public: friend std::ostream &operator<<(std::ostream &_out,
204  const gazebo::math::Vector4 &_pt)
205  {
206  _out << _pt.x << " " << _pt.y << " " << _pt.z << " " << _pt.w;
207  return _out;
208  }
209 
214  public: friend std::istream &operator >> (std::istream &_in,
216  {
217  // Skip white spaces
218  _in.setf(std::ios_base::skipws);
219  _in >> _pt.x >> _pt.y >> _pt.z >> _pt.w;
220  return _in;
221  }
222  };
224  }
225 }
226 #endif
227 
228 
229 
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector4 &_pt)
Stream insertion operator.
Definition: Vector4.hh:203
A 3x3 matrix class.
Definition: Matrix4.hh:40
double Generic x, y, z, w vector
Definition: Vector4.hh:39
double x
X value.
Definition: Vector4.hh:188
double w
W value.
Definition: Vector4.hh:197
#define GZ_MATH_VISIBLE
Definition: system.hh:141
double y
Y value.
Definition: Vector4.hh:191
double z
Z value.
Definition: Vector4.hh:194
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.