All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector2i.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 /* Desc: Two dimensional vector
18  * Author: Nate Koenig
19  * Date: 3 Apr 2007
20  */
21 
22 #ifndef _VECTOR2I_HH_
23 #define _VECTOR2I_HH_
24 
25 #include <math.h>
26 #include <iostream>
27 #include <fstream>
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace math
33  {
36 
40  {
42  public: Vector2i();
43 
47  public: Vector2i(const int &_x, const int &_y);
48 
51  public: Vector2i(const Vector2i &_pt);
52 
54  public: virtual ~Vector2i();
55 
59  public: int Distance(const Vector2i &_pt) const;
60 
62  public: void Normalize();
63 
67  public: void Set(int _x, int _y);
68 
72  public: Vector2i Cross(const Vector2i &_pt) const;
73 
77  public: Vector2i &operator =(const Vector2i &_v);
78 
82  public: const Vector2i &operator =(int _value);
83 
87  public: Vector2i operator+(const Vector2i &_v) const;
88 
92  public: const Vector2i &operator+=(const Vector2i &_v);
93 
97  public: Vector2i operator-(const Vector2i &_v) const;
98 
102  public: const Vector2i &operator-=(const Vector2i &_v);
103 
108  public: const Vector2i operator/(const Vector2i &_v) const;
109 
114  public: const Vector2i &operator/=(const Vector2i &_v);
115 
120  public: const Vector2i operator/(int _v) const;
121 
126  public: const Vector2i &operator/=(int _v);
127 
132  public: const Vector2i operator*(const Vector2i &_v) const;
133 
138  public: const Vector2i &operator*=(const Vector2i &_v);
139 
143  public: const Vector2i operator*(int _v) const;
144 
148  public: const Vector2i &operator*=(int _v);
149 
153  public: bool operator ==(const Vector2i &_v) const;
154 
158  public: bool operator!=(const Vector2i &_v) const;
159 
162  public: bool IsFinite() const;
163 
166  public: int operator[](unsigned int _index) const;
167 
169  public: int x;
170 
172  public: int y;
173 
178  public: friend std::ostream &operator<<(std::ostream &_out,
179  const gazebo::math::Vector2i &_pt)
180  {
181  _out << _pt.x << " " << _pt.y;
182  return _out;
183  }
184 
189  public: friend std::istream &operator>>(std::istream &_in,
191  {
192  // Skip white spaces
193  _in.setf(std::ios_base::skipws);
194  _in >> _pt.x >> _pt.y;
195  return _in;
196  }
197  };
198 
200  }
201 }
202 #endif
203 
204 
205