Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CGAL/include/CGAL/SimpleCartesian/PointS3.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 : webS3/S3.lw
36 // file : include/CGAL/SimpleCartesian/PointS3.h
37 // package : S3 (1.6)
38 // revision : 1.6
39 // revision_date : 28 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 #ifndef CGAL_POINTS3_H
52 #define CGAL_POINTS3_H
53 
55 
56 template < class FT >
57 inline
59 operator+(const Origin& o, const VectorS3<FT>& v);
60 
61 template < class FT >
62 inline
64 operator-(const Origin& o, const VectorS3<FT>& v);
65 
66 
67 template < class FT >
68 class PointS3
69 {
70 friend CGAL_FRIEND_INLINE
72  operator+ CGAL_NULL_TMPL_ARGS( const Origin& o, const VectorS3<FT>& v);
73 
74 friend CGAL_FRIEND_INLINE
76  operator- CGAL_NULL_TMPL_ARGS( const Origin& o, const VectorS3<FT>& v);
77 public:
78  PointS3() {}
79  PointS3(const Origin& o)
80  : e0(FT(0)), e1(FT(0)), e2(FT(0)) {}
81  PointS3(const FT& x, const FT& y, const FT& z)
82  : e0(x), e1(y), e2(z) {}
83  PointS3(const FT& x, const FT& y, const FT& z, const FT& hw);
84 
85  bool operator==(const PointS3<FT>& p) const;
86  bool operator!=(const PointS3<FT>& p) const;
87 
88  const FT& x() const;
89  const FT& y() const;
90  const FT& z() const;
91 
92  const FT& hx() const;
93  const FT& hy() const;
94  const FT& hz() const;
95  FT hw() const;
96 
97  const FT& cartesian(int i) const;
98  const FT& operator[](int i) const;
99 
100  FT homogeneous(int i) const;
101 
102  int dimension() const;
103  Bbox_3 bbox() const;
104 
106 
107 
108 // protected:
109  PointS3(const VectorS3<FT>& v);
110 // private:
111  FT e0;
112  FT e1;
113  FT e2;
114 };
115 
117 
118 #include <CGAL/Origin.h>
119 #include <CGAL/SimpleCartesian/VectorS3.h>
121 #include <CGAL/Bbox_3.h>
122 #include <CGAL/number_utils.h>
123 
125 
126 
127 template < class FT >
128 PointS3<FT>::PointS3(const FT& x, const FT& y, const FT& z, const FT& w)
129 {
130  if (w != FT(1))
131  {
132  e0 = x/w;
133  e1 = y/w;
134  e2 = z/w;
135  }
136  else
137  {
138  e0 = x;
139  e1 = y;
140  e2 = z;
141  }
142 }
143 
144 template < class FT >
146 {
147  e0 = v.e0;
148  e1 = v.e1;
149  e2 = v.e2;
150 }
151 
152 template < class FT >
153 inline
154 bool
156 { return (x() == p.x()) && (y() == p.y()) && (z() == p.z()); }
157 
158 template < class FT >
159 inline
160 bool
162 { return !(*this == p); }
163 
164 
165 template < class FT >
166 inline
167 const FT&
169 { return e0; }
170 
171 
172 template < class FT >
173 inline
174 const FT&
176 { return e1; }
177 
178 
179 template < class FT >
180 inline
181 const FT&
183 { return e2; }
184 
185 
186 template < class FT >
187 inline
188 int
190 { return 3; }
191 
192 
193 template < class FT >
194 inline
195 const FT&
197 {
198  CGAL_kernel_precondition( (i>=0) && (i<=2) );
199  return (i==0) ? x() :
200  (i==1) ? y() : z();
201 }
202 
203 
204 template < class FT >
205 inline
206 const FT&
208 {
209  return cartesian(i);
210 }
211 
212 
213 template < class FT >
214 inline
215 const FT&
217 { return e0; }
218 
219 
220 template < class FT >
221 inline
222 const FT&
224 { return e1; }
225 
226 
227 template < class FT >
228 inline
229 const FT&
231 { return e2; }
232 
233 
234 template < class FT >
235 inline
236 FT
238 { return FT(1); }
239 
240 template < class FT >
241 FT
243 {
244  CGAL_kernel_precondition((i>=0) && (i<=3));
245  return (i<3) ? cartesian(i) : FT(1);
246 }
247 
248 template < class FT >
249 inline
252 { return PointS3<FT>(p.x() + v.x(), p.y() + v.y(), p.z() + v.z()); }
253 
254 template < class FT >
255 inline
258 { return PointS3<FT>(p.x() - v.x(), p.y() - v.y(), p.z() - v.z()); }
259 
260 template < class FT >
261 inline
263 operator+(const Origin& , const VectorS3<FT>& v)
264 { return PointS3<FT>(v); }
265 
266 template < class FT >
267 inline
269 operator-(const Origin& , const VectorS3<FT>& v)
270 { return PointS3<FT>(-v); }
271 
272 template < class FT >
273 inline
276 { return VectorS3<FT>(p.x() - q.x(), p.y() - q.y(), p.z() - q.z()); }
277 
278 
279 template < class FT >
280 inline
282 operator-(const PointS3<FT>& p, const Origin& )
283 { return VectorS3<FT>(p); }
284 
285 
286 template < class FT >
287 inline
289 operator-(const Origin& , const PointS3<FT>& p)
290 { return VectorS3<FT>(-p.x(), -p.y(), -p.z()); }
291 
292 
293 template < class FT >
294 inline
297 { return t.transform(*this); }
298 
299 
300 template < class FT >
302 {
303  // Not robust...
304  double bx = CGAL::to_double(x());
305  double by = CGAL::to_double(y());
306  double bz = CGAL::to_double(z());
307  return Bbox_3(bx, by, bz, bx, by, bz);
308 }
309 
310 
311 #ifndef CGAL_NO_OSTREAM_INSERT_POINTS3
312 template < class FT >
313 std::ostream& operator<<(std::ostream& os, const PointS3<FT>& p)
314 {
315  switch(os.iword(IO::mode)) {
316  case IO::ASCII :
317  return os << p.x() << ' ' << p.y() << ' ' << p.z();
318  case IO::BINARY :
319  write(os, p.x());
320  write(os, p.y());
321  write(os, p.z());
322  return os;
323  default:
324  os << "PointS3(" << p.x() << ", " << p.y() << ", " << p.z() << ")";
325  return os;
326  }
327 }
328 #endif // CGAL_NO_OSTREAM_INSERT_POINTS3
329 
330 #ifndef CGAL_NO_ISTREAM_EXTRACT_POINTS3
331 template < class FT >
332 std::istream& operator>>(std::istream& is, PointS3<FT>& p)
333 {
334  FT x, y, z;
335  switch(is.iword(IO::mode)) {
336  case IO::ASCII :
337  is >> x >> y >> z;
338  break;
339  case IO::BINARY :
340  read(is, x);
341  read(is, y);
342  read(is, z);
343  break;
344  default:
345  CGAL_kernel_assertion_msg(false,"Stream must be in ascii or binary mode"
346 );
347  // throw ios_base::failure("Stream must be in ascii or binary mode");
348  break;
349  }
350  p = PointS3<FT>(x, y, z);
351  return is;
352 }
353 #endif // CGAL_NO_ISTREAM_EXTRACT_POINTS3
354 
355 
357 
358 #endif // CGAL_POINTS3_H
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
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_assertion_msg(EX, MSG)
bool operator!=(const PointS3< FT > &p) const
Iterator_from_circulator< C, Ref, Ptr > operator+(Dist n, const Iterator_from_circulator< C, Ref, Ptr > &circ)
Definition: circulator.h:689
*********************************************************************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 int int int REAL REAL REAL * z
Definition: write.cpp:76
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
bool operator==(const PointS3< FT > &p) const
PointS3< FT > transform(const PointS3< FT > &p) const
static int mode
Definition: io.h:63
Definition: io.h:64
const FT & operator[](int i) 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
PointS3< FT > transform(const Aff_transformationS3< FT > &) const
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
PointS3(const FT &x, const FT &y, const FT &z)
const FT & cartesian(int i) const
#define CGAL_NULL_TMPL_ARGS
Definition: config.h:120
#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)
#define CGAL_FRIEND_INLINE
Definition: kernel_basic.h:61