Vector2i.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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  * WITHOUint 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 #ifndef _GAZEBO_VECTOR2I_HH_
18 #define _GAZEBO_VECTOR2I_HH_
19 
20 #include <math.h>
21 #include <iostream>
22 #include <fstream>
23 #include <ignition/math/Vector2.hh>
24 
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace math
30  {
33 
37  {
39  public: Vector2i();
40 
44  public: Vector2i(const int &_x, const int &_y);
45 
48  public: Vector2i(const Vector2i &_pt);
49 
52  public: Vector2i(const ignition::math::Vector2i &_pt);
53 
55  public: virtual ~Vector2i();
56 
60  public: int Distance(const Vector2i &_pt) const;
61 
63  public: void Normalize();
64 
68  public: void Set(int _x, int _y);
69 
73  public: Vector2i Cross(const Vector2i &_pt) const;
74 
78  public: Vector2i &operator =(const Vector2i &_v);
79 
83  public: Vector2i &operator =(const ignition::math::Vector2i &_v);
84 
88  public: const Vector2i &operator =(int _value);
89 
93  public: Vector2i operator+(const Vector2i &_v) const;
94 
98  public: const Vector2i &operator+=(const Vector2i &_v);
99 
103  public: Vector2i operator-(const Vector2i &_v) const;
104 
108  public: const Vector2i &operator-=(const Vector2i &_v);
109 
114  public: const Vector2i operator/(const Vector2i &_v) const;
115 
120  public: const Vector2i &operator/=(const Vector2i &_v);
121 
126  public: const Vector2i operator/(int _v) const;
127 
132  public: const Vector2i &operator/=(int _v);
133 
138  public: const Vector2i operator*(const Vector2i &_v) const;
139 
144  public: const Vector2i &operator*=(const Vector2i &_v);
145 
149  public: const Vector2i operator*(int _v) const;
150 
154  public: const Vector2i &operator*=(int _v);
155 
159  public: bool operator ==(const Vector2i &_v) const;
160 
164  public: bool operator!=(const Vector2i &_v) const;
165 
168  public: bool IsFinite() const;
169 
172  public: int operator[](unsigned int _index) const;
173 
177  public: ignition::math::Vector2i Ign() const;
178 
180  public: int x;
181 
183  public: int y;
184 
189  public: friend std::ostream &operator<<(std::ostream &_out,
190  const gazebo::math::Vector2i &_pt)
191  {
192  _out << _pt.x << " " << _pt.y;
193  return _out;
194  }
195 
200  public: friend std::istream &operator>>(std::istream &_in,
202  {
203  // Skip white spaces
204  _in.setf(std::ios_base::skipws);
205  _in >> _pt.x >> _pt.y;
206  return _in;
207  }
208  };
209 
211  }
212 }
213 #endif
214 
215 
216 
Generic integer x, y vector.
Definition: Vector2i.hh:36
friend std::istream & operator>>(std::istream &_in, gazebo::math::Vector2i &_pt)
Stream extraction operator.
Definition: Vector2i.hh:200
#define GZ_MATH_VISIBLE
Definition: system.hh:134
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Vector2i &_pt)
Stream insertion operator.
Definition: Vector2i.hh:189
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
int x
x data
Definition: Vector2i.hh:180
int y
y data
Definition: Vector2i.hh:183