4
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
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.
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.
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
21
// Please report all bugs and problems to <gmsh@geuz.org>.
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]; }
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; }
49
inline SPoint2 operator + (const SPoint2 &a, const SPoint2 &b)
50
{ return SPoint2(a.x()+b.x(),a.y()+b.y()); }
52
inline SPoint2 operator - (const SPoint2 &a, const SPoint2 &b)
53
{ return SPoint2(a.x()-b.x(),a.y()-b.y()); }
55
inline void SPoint2::setPosition(double xx, double yy)
56
{ P[0] = xx; P[1] = yy; }
58
inline void SPoint2::getPosition(double *xx, double *yy) const
59
{ *xx = P[0]; *yy = P[1]; }
61
inline void SPoint2::position(double *p) const
62
{ p[0] = P[0]; p[1] = P[1]; }
64
inline double SPoint2::x(void) const
67
inline double SPoint2::y(void) const
70
inline SPoint2 & SPoint2::operator=(const SPoint2 &p)
71
{ P[0] = p.P[0]; P[1]=p.P[1]; return *this; }
73
inline double &SPoint2::operator[](int i)
76
inline double SPoint2::operator[](int i) const
79
inline void SPoint2::operator+=(const SPoint2 &p)
80
{ P[0] += p.P[0]; P[1] += p.P[1];}
82
inline void SPoint2::operator-=(const SPoint2 &p)
83
{ P[0] -= p.P[0]; P[1] -= p.P[1];}
85
inline void SPoint2::operator*=(double mult)
86
{ P[0] *= mult; P[1] *= mult; }
88
inline SPoint2 SPoint2::operator*(double mult)
89
{ return SPoint2(P[0]*mult, P[1]*mult); }