~ubuntu-branches/ubuntu/intrepid/gmsh/intrepid

« back to all changes in this revision

Viewing changes to Geo/SPoint2.h

  • Committer: Bazaar Package Importer
  • Author(s): Emmet Hikory
  • Date: 2007-05-07 10:01:37 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070507100137-6j0rzz1ucbn0m2jt
Tags: 2.0.7-1ubuntu1
* Merged with Debian unstable.  Remaining Ubuntu changes:
  - Add .desktop file
  - Add icon
* Added XSBC-Original-Maintainer
* Removed Application Category from gmsh.desktop
* Link against GLU (fixes FTBFS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _SPOINT2_H_
 
2
#define _SPOINT2_H_
 
3
 
 
4
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 
5
//
 
6
// This program is free software; you can redistribute it and/or modify
 
7
// it under the terms of the GNU General Public License as published by
 
8
// the Free Software Foundation; either version 2 of the License, or
 
9
// (at your option) any later version.
 
10
//
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
// GNU General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public License
 
17
// along with this program; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
19
// USA.
 
20
// 
 
21
// Please report all bugs and problems to <gmsh@geuz.org>.
 
22
 
 
23
#include <math.h>
 
24
 
 
25
// A point in 2-space
 
26
class SPoint2 {
 
27
 protected:
 
28
  double P[2];
 
29
 public:
 
30
  SPoint2(double x=0.0, double y=0.0) {P[0] = x; P[1] = y;}
 
31
  SPoint2(double *p) {P[0] = p[0]; P[1] = p[1];}
 
32
  SPoint2(const SPoint2 &pt) {P[0] = pt.P[0]; P[1] = pt.P[1]; }
 
33
  virtual ~SPoint2() {}
 
34
  void setPosition(double xx, double yy);
 
35
  void getPosition(double *xx, double *yy) const;
 
36
  void position(double *) const;
 
37
  inline double x(void) const;
 
38
  inline double y(void) const;
 
39
  double &operator[](int);
 
40
  double operator[](int) const;
 
41
  SPoint2 &operator=(const SPoint2 &p);
 
42
  void operator+=(const SPoint2 &p);
 
43
  void operator-=(const SPoint2 &p);
 
44
  void operator*=(double mult);
 
45
  SPoint2 operator*(double mult);
 
46
  operator double *() { return P; }
 
47
};
 
48
 
 
49
inline SPoint2 operator + (const SPoint2 &a, const SPoint2 &b)
 
50
{ return SPoint2(a.x()+b.x(),a.y()+b.y()); }
 
51
 
 
52
inline SPoint2 operator - (const SPoint2 &a, const SPoint2 &b)
 
53
{ return SPoint2(a.x()-b.x(),a.y()-b.y()); }
 
54
 
 
55
inline void SPoint2::setPosition(double xx, double yy)
 
56
{ P[0] = xx;  P[1] = yy; }
 
57
 
 
58
inline void SPoint2::getPosition(double *xx, double *yy) const
 
59
{ *xx = P[0];  *yy = P[1]; }
 
60
 
 
61
inline void SPoint2::position(double *p) const
 
62
{ p[0] = P[0]; p[1] = P[1]; }
 
63
 
 
64
inline double SPoint2::x(void) const
 
65
{ return P[0]; }
 
66
 
 
67
inline double SPoint2::y(void) const
 
68
{ return P[1]; }
 
69
 
 
70
inline SPoint2 & SPoint2::operator=(const SPoint2 &p)
 
71
{ P[0] = p.P[0]; P[1]=p.P[1]; return *this; }
 
72
 
 
73
inline double &SPoint2::operator[](int i)
 
74
{ return P[i]; }
 
75
 
 
76
inline double SPoint2::operator[](int i) const
 
77
{ return P[i]; }
 
78
 
 
79
inline void SPoint2::operator+=(const SPoint2 &p)
 
80
{ P[0] += p.P[0]; P[1] += p.P[1];}
 
81
 
 
82
inline void SPoint2::operator-=(const SPoint2 &p)
 
83
{ P[0] -= p.P[0]; P[1] -= p.P[1];}
 
84
 
 
85
inline void SPoint2::operator*=(double mult)
 
86
{ P[0] *= mult; P[1] *= mult; }
 
87
 
 
88
inline SPoint2 SPoint2::operator*(double mult)
 
89
{ return SPoint2(P[0]*mult, P[1]*mult); }
 
90
 
 
91
#endif