Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CGAL/include/CGAL/SimpleCartesian/PointS2.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1999 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 // release : CGAL-2.2
33 // release_date : 2000, September 30
34 //
35 // source : webS2/S2.lw
36 // file : include/CGAL/SimpleCartesian/PointS2.h
37 // package : S2 (1.7)
38 // revision : 1.6
39 // revision_date : 27 Jun 2000
40 // author(s) : Stefan Schirra
41 // based on code by
42 // Andreas Fabri and
43 // Herve Brönnimann
44 //
45 // coordinator : MPI, Saarbrücken
46 // email : contact@cgal.org
47 // www : http://www.cgal.org
48 //
49 // ======================================================================
50 
51 
52 #ifndef CGAL_POINTS2_H
53 #define CGAL_POINTS2_H
54 
56 
57 template < class FT >
58 class PointS2
59 {
60  public:
61  PointS2() {}
62  PointS2(const Origin& ) : e0(FT(0)), e1(FT(0)) {}
63  PointS2(const FT& hx, const FT& hy, const FT& hw);
64  PointS2(const FT& x, const FT& y);
65 
66  bool operator==(const PointS2<FT>& p) const;
67  bool operator!=(const PointS2<FT>& p) const;
68 
69  const FT& hx() const;
70  const FT& hy() const;
71  FT hw() const;
72  const FT& x() const;
73  const FT& y() const;
74  FT cartesian(int i) const;
75  FT operator[](int i) const;
76  FT homogeneous(int i) const;
77 
78  int dimension() const;
79  Bbox_2 bbox() const;
80 
81 
83 
84 // protected:
85  PointS2(const VectorS2<FT>& v);
86 
87  FT e0;
88  FT e1;
89 };
90 
91 
93 
94 #include <CGAL/Origin.h>
95 #include <CGAL/SimpleCartesian/VectorS2.h>
97 #include <CGAL/Bbox_2.h>
98 #include <CGAL/number_utils.h>
99 
101 
102 template < class FT >
105 { e0 = v.e0; e1 = v.e1; }
106 
107 template < class FT >
109 PointS2<FT>::PointS2(const FT& hx, const FT& hy, const FT& hw)
110 {
111  if( hw != FT(1))
112  { e0 = hx/hw; e1 = hy/hw; }
113  else
114  { e0 = hx; e1 = hy; }
115 }
116 
117 template < class FT >
119 PointS2<FT>::PointS2(const FT& x, const FT& y)
120 { e0 = x; e1 = y; }
121 
122 template < class FT >
123 inline
124 bool
126 { return ((x() == p.x()) && (y() == p.y())) ; }
127 
128 template < class FT >
129 inline
130 bool
132 { return !(*this == p); }
133 
134 template < class FT >
135 inline
136 const FT&
138 { return e0; }
139 
140 template < class FT >
141 inline
142 const FT&
144 { return e1 ; }
145 
146 template < class FT >
148 FT
150 {
151  CGAL_kernel_precondition( (i == 0) || (i == 1) );
152  return (i == 0) ? x() : y();
153 }
154 
155 template < class FT >
156 inline
157 FT
159 { return cartesian(i); }
160 
161 template < class FT >
162 inline
163 int
165 { return 2; }
166 
167 template < class FT >
168 inline
169 const FT&
171 { return e0; }
172 
173 template < class FT >
174 inline
175 const FT&
177 { return e1; }
178 
179 template < class FT >
180 inline
181 FT
183 { return FT(1); }
184 
185 template < class FT >
186 inline
187 FT
189 {
190  CGAL_kernel_precondition( (i>=0) && (i<=2) );
191  if (i<2) return cartesian(i);
192  return FT(1);
193 }
194 
195 template < class FT >
196 inline
199 { return PointS2<FT>(p.x() + v.x(), p.y() + v.y()) ; }
200 
201 template < class FT >
202 inline
205 { return PointS2<FT>(p.x() - v.x(), p.y() - v.y()) ; }
206 
207 template < class FT >
208 inline
210 operator+(const Origin& , const VectorS2<FT>& v)
211 { return PointS2<FT>(v) ; }
212 
213 template < class FT >
214 inline
216 { return PointS2<FT>(-v) ; }
217 
218 template < class FT >
219 inline
222 { return VectorS2<FT>(p.x() - q.x(), p.y() - q.y()) ; }
223 
224 template < class FT >
225 inline
227 operator-(const PointS2<FT>& p, const Origin& )
228 { return VectorS2<FT>(p) ; }
229 
230 template < class FT >
231 inline
233 operator-(const Origin& , const PointS2<FT>& p)
234 { return VectorS2<FT>(-p.x(), -p.y()) ; }
235 
236 template < class FT >
240 { return t.transform(*this); }
241 
242 template < class FT >
244 Bbox_2
246 {
247  double bx = CGAL::to_double(x());
248  double by = CGAL::to_double(y());
249  return Bbox_2(bx,by, bx,by);
250 }
251 
252 #ifndef CGAL_NO_OSTREAM_INSERT_POINTS2
253 template < class FT >
254 std::ostream&
255 operator<<(std::ostream& os, const PointS2<FT>& p)
256 {
257  switch(os.iword(IO::mode))
258  {
259  case IO::ASCII :
260  return os << p.x() << ' ' << p.y();
261  case IO::BINARY :
262  write(os, p.x());
263  write(os, p.y());
264  return os;
265  default:
266  return os << "PointS2(" << p.x() << ", " << p.y() << ')';
267  }
268 }
269 #endif // CGAL_NO_OSTREAM_INSERT_POINTS2
270 
271 #ifndef CGAL_NO_ISTREAM_EXTRACT_POINTS2
272 template < class FT >
273 std::istream&
274 operator>>(std::istream& is, PointS2<FT>& p)
275 {
276  FT x, y;
277  switch(is.iword(IO::mode))
278  {
279  case IO::ASCII :
280  is >> x >> y;
281  break;
282  case IO::BINARY :
283  read(is, x);
284  read(is, y);
285  break;
286  default:
287  CGAL_kernel_assertion_msg(false,"Stream must be in ascii or binary mode");
288  // throw ios_base::failure("Stream must be in ascii or binary mode");
289  }
290  p = PointS2<FT>(x, y);
291  return is;
292 }
293 #endif // CGAL_NO_ISTREAM_EXTRACT_POINTS2
294 
296 
297 #endif // CGAL_POINTS2_H
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
#define CGAL_KERNEL_CTOR_INLINE
Definition: kernel_basic.h:57
CGAL_BEGIN_NAMESPACE double to_double(double d)
Definition: double.h:68
void int int REAL REAL * y
Definition: read.cpp:74
#define CGAL_KERNEL_INLINE
Definition: kernel_basic.h:54
#define CGAL_kernel_assertion_msg(EX, MSG)
bool operator!=(const PointS2< FT > &p) const
Iterator_from_circulator< C, Ref, Ptr > operator+(Dist n, const Iterator_from_circulator< C, Ref, Ptr > &circ)
Definition: circulator.h:689
bool operator==(const PointS2< FT > &p) const
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Definition: io.h:64
void write(std::ostream &os, const T &t, const io_Read_write &)
Definition: io.h:96
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
static int mode
Definition: io.h:63
Definition: io.h:64
PointS2< FT > transform(const PointS2< FT > &p) const
NT q
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
PointS2< FT > transform(const Aff_transformationS2< FT > &) const
#define CGAL_kernel_precondition(EX)
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
Point_2< R > operator-(const Origin &o, const Vector_2< R > &v)