Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CGAL/include/CGAL/SimpleCartesian/VectorS3.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/VectorS3.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_VECTORS3_H
52 #define CGAL_VECTORS3_H
53 
54 #include <CGAL/SimpleCartesian/PointS3.h>
55 
57 
58 template < class FT >
59 inline VectorS3<FT>
60 operator-(const PointS3<FT>& p, const Origin& o);
61 
62 template < class FT >
63 class VectorS3
64 {
65 
66 friend class DirectionS3<FT>;
67 
68 public:
69  VectorS3() {}
71  : e0(FT(0)), e1(FT(0)), e2(FT(0)) {}
72  VectorS3(const FT& x, const FT& y, const FT& z)
73  : e0(x), e1(y), e2(z) {}
74  VectorS3(const FT& x, const FT& y, const FT& z, const FT& w);
75 
76 
77  bool operator==(const VectorS3<FT>& p) const;
78  bool operator!=(const VectorS3<FT>& p) const;
79 
80  bool operator==(const Null_vector& ) const;
81  bool operator!=(const Null_vector& ) const;
82 
83  const FT& x() const;
84  const FT& y() const;
85  const FT& z() const;
86  const FT& cartesian(int i) const;
87  const FT& operator[](int i) const;
88 
89  const FT& hx() const;
90  const FT& hy() const;
91  const FT& hz() const;
92  FT hw() const;
93  FT homogeneous(int i) const;
94 
95  int dimension() const;
96 
97  VectorS3<FT> operator+(const VectorS3<FT>& w) const;
98  VectorS3<FT> operator-(const VectorS3<FT>& w) const;
99  VectorS3<FT> operator-() const;
100  FT operator*(const VectorS3<FT>& w) const;
101  VectorS3<FT> operator/(const FT& c) const;
102  DirectionS3<FT> direction() const;
104 
105 // protected:
106  VectorS3(const PointS3<FT>& p);
107  VectorS3(const DirectionS3<FT>& p);
108 
109 // private:
110  FT e0;
111  FT e1;
112  FT e2;
113 };
114 
115 
117 
119 
121 
122 
123 template < class FT >
124 VectorS3<FT>::VectorS3(const FT& x, const FT& y, const FT& z, const FT& w)
125 {
126  if (w != FT(1))
127  {
128  e0 = x/w;
129  e1 = y/w;
130  e2 = z/w;
131  }
132  else
133  {
134  e0 = x;
135  e1 = y;
136  e2 = z;
137  }
138 }
139 
140 template < class FT >
142 {
143  e0 = p.e0;
144  e1 = p.e1;
145  e2 = p.e2;
146 }
147 
148 template < class FT >
150 {
151  e0 = d.e0;
152  e1 = d.e1;
153  e2 = d.e2;
154 }
155 
156 template < class FT >
157 bool
159 { return (x() == v.x()) && (y() == v.y()) && (z() == v.z()) ; }
160 
161 template < class FT >
162 inline
163 bool
165 { return !(*this == v); }
166 
167 
168 template < class FT >
169 bool
171 { return (x() == FT(0)) && (y() == FT(0)) && (z() == FT(0)) ; }
172 
173 template < class FT >
174 inline
175 bool
177 { return !(*this == v); }
178 
179 template < class FT >
180 inline
181 const FT&
183 { return e0; }
184 
185 template < class FT >
186 inline
187 const FT&
189 { return e1; }
190 
191 template < class FT >
192 inline
193 const FT&
195 { return e2; }
196 
197 template < class FT >
198 inline
199 const FT&
201 {
202  CGAL_kernel_precondition( (i>=0) && (i<3) );
203  return (i==0) ? x() :
204  (i==1) ? y() : z();
205 }
206 
207 template < class FT >
208 inline
209 const FT&
211 { return cartesian(i); }
212 
213 template < class FT >
214 inline
215 int
217 { return 3; }
218 
219 template < class FT >
220 inline
221 const FT&
223 { return e0; }
224 
225 template < class FT >
226 inline
227 const FT&
229 { return e1; }
230 
231 template < class FT >
232 inline
233 const FT&
235 { return e2; }
236 
237 template < class FT >
238 FT
240 { return FT(1); }
241 
242 template < class FT >
243 FT
245 { return (i==3) ? FT(1) : cartesian(i); }
246 
247 template < class FT >
248 inline
251 { return VectorS3<FT>(x() + w.x(), y() + w.y(), z() + w.z()) ; }
252 
253 template < class FT >
254 inline
257 { return VectorS3<FT>(x() - w.x(), y() - w.y(), z() - w.z()) ; }
258 
259 template < class FT >
260 inline
263 { return VectorS3<FT>(-x(), -y(), -z()) ; }
264 
265 template < class FT >
266 inline
267 FT
269 { return x() * w.x() + y() * w.y() + z() * w.z() ; }
270 
271 template < class FT >
272 inline
274 operator*(const FT& c, const VectorS3<FT>& w)
275 { return VectorS3<FT>( c* w.x(), c * w.y(), c * w.z()) ; }
276 
277 template < class FT >
278 inline
280 VectorS3<FT>::operator/(const FT& c) const
281 { return VectorS3<FT>( x()/c, y()/c, z()/c) ; }
282 
283 template < class FT >
286 {
287  return VectorS3<FT>( v.y() * w.z() - v.z() * w.y() ,
288  v.z() * w.x() - v.x() * w.z() ,
289  v.x() * w.y() - v.y() * w.x() );
290 }
291 
292 template < class FT >
293 inline
296 { return DirectionS3<FT>(*this); }
297 
298 
299 template < class FT >
302 { return t.transform(*this); }
303 
304 
305 #ifndef CGAL_NO_OSTREAM_INSERT_VECTORS3
306 template < class FT >
307 std::ostream& operator<<(std::ostream& os, const VectorS3<FT>& v)
308 {
309  switch(os.iword(IO::mode)) {
310  case IO::ASCII :
311  return os << v.x() << ' ' << v.y() << ' ' << v.z();
312  case IO::BINARY :
313  write(os, v.x());
314  write(os, v.y());
315  write(os, v.z());
316  return os;
317  default:
318  os << "VectorS3(" << v.x() << ", " << v.y() << ", " << v.z() << ")";
319  return os;
320  }
321 }
322 #endif // CGAL_NO_OSTREAM_INSERT_VECTORS3
323 
324 #ifndef CGAL_NO_ISTREAM_EXTRACT_VECTORS3
325 template < class FT >
326 std::istream& operator>>(std::istream& is, VectorS3<FT>& p)
327 {
328  FT x, y, z;
329  switch(is.iword(IO::mode)) {
330  case IO::ASCII :
331  is >> x >> y >> z;
332  break;
333  case IO::BINARY :
334  read(is, x);
335  read(is, y);
336  read(is, z);
337  break;
338  default:
339  CGAL_kernel_assertion_msg(false,"Stream must be in ascii or binary mode");
340  // throw ios_base::failure("Stream must be in ascii or binary mode");
341  break;
342  }
343  p = VectorS3<FT>(x, y, z);
344  return is;
345 }
346 #endif // CGAL_NO_ISTREAM_EXTRACT_VECTORS3
347 
348 
350 
351 #endif
Vector_3< T > operator*(T t, const Vector_3< T > &v)
Definition: mapbasic.h:139
const NT & d
void int int REAL REAL * y
Definition: read.cpp:74
#define CGAL_kernel_assertion_msg(EX, MSG)
VectorS3< FT > transform(const Aff_transformationS3< FT > &) const
bool operator==(const VectorS3< 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
VectorS3< FT > operator+(const VectorS3< FT > &w) const
VectorS3< FT > operator/(const FT &c) const
void int int int REAL REAL REAL * z
Definition: write.cpp:76
const FT & cartesian(int i) const
VectorS3< FT > cross_product(const VectorS3< FT > &v, const VectorS3< FT > &w)
void write(std::ostream &os, const T &t, const io_Read_write &)
Definition: io.h:96
VectorS3(const FT &x, const FT &y, const FT &z)
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
PointS3< FT > transform(const PointS3< FT > &p) const
static int mode
Definition: io.h:63
Definition: io.h:64
FT operator*(const VectorS3< FT > &w) const
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)
#define CGAL_kernel_precondition(EX)
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
bool operator!=(const VectorS3< FT > &p) const
Point_2< R > operator-(const Origin &o, const Vector_2< R > &v)
const FT & operator[](int i) const
VectorS3< FT > operator-() const
DirectionS3< FT > direction() const