xc
SlidingVector2d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //SlidingVector2d.h
22 
23 #ifndef VDESLIZ2D_H
24 #define VDESLIZ2D_H
25 
26 
27 #include "Pos2d.h"
28 #include "Vector2d.h"
29 #include "utility/utils/misc_utils/mchne_eps.h"
30 
31 
33 //
35 class SlidingVector2d : public Vector2d
36  {
37  Pos2d org;
38  public:
39  SlidingVector2d(const Pos2d &o= Pos2d(),const Vector2d &v= Vector2d())
40  : Vector2d(v), org(o) {}
41  SlidingVector2d(const Pos2d &o,const Pos2d &p);
42 
43  bool operator==(const SlidingVector2d &) const;
44 
45  virtual GEOM_FT getMoment(const Pos2d &o) const;
46  virtual const Pos2d &getOrg(void) const
47  { return org; }
48  const Pos2d getDest(void) const
49  { return org+(const Vector2d &)(*this); }
50  const Vector2d &getVector(void) const;
51  Vector2d getVector2d(void) const;
52  SlidingVector2d &operator*=(const GEOM_FT &);
53  friend SlidingVector2d operator*(const SlidingVector2d &m,const GEOM_FT &p);
54  friend SlidingVector2d operator*(const GEOM_FT &p,const SlidingVector2d &m);
55  friend SlidingVector2d operator/(const SlidingVector2d &m,const GEOM_FT &p);
56  friend std::ostream &operator<<(std::ostream &os,const SlidingVector2d &v);
57  };
58 
59 SlidingVector2d operator*(const SlidingVector2d &m,const GEOM_FT &p);
60 SlidingVector2d operator*(const GEOM_FT &p,const SlidingVector2d &m);
61 SlidingVector2d operator/(const SlidingVector2d &m,const GEOM_FT &p);
62 std::ostream &operator<<(std::ostream &os,const SlidingVector2d &v);
63 SlidingVector2d operator-(const SlidingVector2d &v);
64 
65 inline GEOM_FT Abs(const SlidingVector2d &v)
66  { return v.GetModulus(); }
67 
68 #endif
Vector2d getVector2d(void) const
Return the vector part of the object.
Definition: SlidingVector2d.cc:51
sliding vector en dos dimensiones.
Definition: SlidingVector2d.h:35
virtual GEOM_FT GetModulus(void) const
Return el módulo del vector.
Definition: Vector2d.cc:193
const Vector2d & getVector(void) const
Return the vector part of the object.
Definition: SlidingVector2d.cc:44
Posición en dos dimensiones.
Definition: Pos2d.h:41
Vector en dos dimensiones.
Definition: Vector2d.h:40
bool operator==(const SlidingVector2d &) const
Comparison operator.
Definition: SlidingVector2d.cc:55
virtual GEOM_FT getMoment(const Pos2d &o) const
Moment of a sliding vector with respect to a point.
Definition: SlidingVector2d.cc:30