GUIDOLib  1.7.7
Guido Engine Internal Documentation
NVPoint.h
1 #ifndef NVPoint_H
2 #define NVPoint_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
7  Copyright (C) 2003 Grame
8 
9  This Source Code Form is subject to the terms of the Mozilla Public
10  License, v. 2.0. If a copy of the MPL was not distributed with this
11  file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
14  research@grame.fr
15 
16 */
17 
18 #include <iostream>
19 
20 class NVPoint
21 {
22  public:
23 
24  NVPoint() : x( 0 ), y( 0 ) { }
25  NVPoint( float p_x, float p_y ) : x( p_x ), y( p_y ) { }
26  NVPoint( const NVPoint & nvp )
27  {
28  x = nvp.x;
29  y = nvp.y;
30  }
31 
32  ~NVPoint() { }
33 
34  void Print( std::ostream& os ) const { os << "[" << x << "," << y << "]"; }
35  void Set( float inX, float inY ) { x = inX; y = inY; }
36 
37  NVPoint & operator=(const NVPoint & p)
38  {
39  x = p.x;
40  y = p.y;
41  return *this;
42  }
43 
44  NVPoint & operator-=(const NVPoint & p)
45  {
46  x -= p.x;
47  y -= p.y;
48  return *this;
49  }
50 
51  NVPoint & operator+=(const NVPoint & p)
52  {
53  x += p.x;
54  y += p.y;
55  return *this;
56  }
57 
58  bool operator==(const NVPoint & p) const
59  {
60  return (x == p.x && y == p.y);
61  }
62 
63  bool operator!=(const NVPoint & p) const
64  {
65  return (x != p.x || y != p.y);
66  }
67 
68  float x;
69  float y;
70 };
71 
72 
73 std::ostream& operator<< (std::ostream& os, const NVPoint& p);
74 
75 // - Globals -
76 NVPoint operator-( const NVPoint & p1, const NVPoint & p2 );
77 NVPoint operator+( const NVPoint & p1, const NVPoint & p2 );
78 
79 inline NVPoint operator-( const NVPoint & p1, const NVPoint & p2 )
80 {
81  return (NVPoint( p1.x - p2.x, p1.y - p2.y ));
82 }
83 
84 inline NVPoint operator+( const NVPoint & p1, const NVPoint & p2 )
85 {
86  return (NVPoint( p1.x + p2.x, p1.y + p2.y ));
87 }
88 
89 
90 
91 #endif
NVPoint::Set
void Set(float inX, float inY)
Definition: NVPoint.h:35
NVPoint::operator-=
NVPoint & operator-=(const NVPoint &p)
Definition: NVPoint.h:44
NVPoint::x
float x
Definition: NVPoint.h:68
NVPoint
Definition: NVPoint.h:20
NVPoint::operator=
NVPoint & operator=(const NVPoint &p)
Definition: NVPoint.h:37
NVPoint::~NVPoint
~NVPoint()
Definition: NVPoint.h:32
NVPoint::NVPoint
NVPoint(float p_x, float p_y)
Definition: NVPoint.h:25
NVPoint::NVPoint
NVPoint(const NVPoint &nvp)
Definition: NVPoint.h:26
NVPoint::y
float y
Definition: NVPoint.h:69
NVPoint::operator==
bool operator==(const NVPoint &p) const
Definition: NVPoint.h:58
NVPoint::operator!=
bool operator!=(const NVPoint &p) const
Definition: NVPoint.h:63
NVPoint::operator+=
NVPoint & operator+=(const NVPoint &p)
Definition: NVPoint.h:51
NVPoint::Print
void Print(std::ostream &os) const
Definition: NVPoint.h:34
NVPoint::NVPoint
NVPoint()
Definition: NVPoint.h:24
operator<<
std::ostream & operator<<(std::ostream &os, const svgendl &eol)

Guido Project Copyright © 2019 Grame-CNCM