Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DirectionS3.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/DirectionS3.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_DIRECTIONS3_H
52 #define CGAL_DIRECTIONS3_H
53 
54 #include <CGAL/SimpleCartesian/VectorS3.h>
55 
57 
58 template < class FT >
60 {
61 public:
63  DirectionS3(const VectorS3<FT>& v);
64  DirectionS3(const FT& x, const FT& y, const FT& z)
65  : e0(x), e1(y), e2(z) {}
66 
67  bool operator==(const DirectionS3<FT>& d) const;
68  bool operator!=(const DirectionS3<FT>& d) const;
69 
70  VectorS3<FT> to_vector() const;
71  VectorS3<FT> vector() const { return to_vector(); }
72 
73 
75 
76  DirectionS3 operator-() const;
77 
78  const FT& delta(int i) const;
79  const FT& dx() const;
80  const FT& dy() const;
81  const FT& dz() const;
82 
83  const FT& hdx() const;
84  const FT& hdy() const;
85  const FT& hdz() const;
86  FT hw() const;
87 
88 
89 // private:
90  FT e0;
91  FT e1;
92  FT e2;
93 };
94 
95 template < class FT >
97 {
98  e0 = v.e0;
99  e1 = v.e1;
100  e2 = v.e2;
101 }
102 
103 template < class FT >
104 bool
106 {
107  return ( dx()*d.dy() == dy()*d.dx() )
108  &&( dx()*d.dz() == dz()*d.dx() )
109  &&( dy()*d.dz() == dz()*d.dy() )
110  &&( CGAL_NTS sign( dx() ) == CGAL_NTS sign( d.dx() ) )
111  &&( CGAL_NTS sign( dy() ) == CGAL_NTS sign( d.dy() ) )
112  &&( CGAL_NTS sign( dz() ) == CGAL_NTS sign( d.dz() ) );
113 }
114 
115 template < class FT >
116 inline
117 bool
119 { return !(*this == d); }
120 
121 template < class FT >
122 inline
125 { return VectorS3<FT>(*this); }
126 
127 
128 template < class FT >
129 inline
132 { return t.transform(*this); }
133 
134 
135 template < class FT >
136 inline
139 { return DirectionS3<FT>(-dx(), -dy(), -dz()); }
140 
141 
142 template < class FT >
143 const FT&
145 {
146  CGAL_kernel_precondition( i >= 0 && i <= 2 );
147  return (i==0) ? dx() :
148  (i==1) ? dy() : dz() ;
149 }
150 
151 
152 template < class FT >
153 inline
154 const FT&
156 { return e0; }
157 
158 
159 template < class FT >
160 inline
161 const FT&
163 { return e1; }
164 
165 
166 template < class FT >
167 inline
168 const FT&
170 { return e2; }
171 
172 template < class FT >
173 inline
174 const FT&
176 { return e0; }
177 
178 
179 template < class FT >
180 inline
181 const FT&
183 { return e1; }
184 
185 
186 template < class FT >
187 inline
188 const FT&
190 { return e2; }
191 
192 template < class FT >
193 inline
194 FT
196 { return FT(1); }
197 
198 
199 
200 #ifndef CGAL_NO_OSTREAM_INSERT_DIRECTIONS3
201 template < class FT >
202 std::ostream& operator<<(std::ostream& os, const DirectionS3<FT>& d)
203 {
204  VectorS3<FT> v = d.vector();
205  switch(os.iword(IO::mode)) {
206  case IO::ASCII :
207  return os << v.x() << ' ' << v.y() << ' ' << v.z();
208  case IO::BINARY :
209  write(os, v.x());
210  write(os, v.y());
211  write(os, v.z());
212  return os;
213  default:
214  os << "DirectionS3(" << v.x() << ", " << v.y() << ", " << v.z() << ")";
215  return os;
216  }
217 }
218 #endif // CGAL_NO_OSTREAM_INSERT_DIRECTIONS3
219 
220 #ifndef CGAL_NO_ISTREAM_EXTRACT_DIRECTIONS3
221 template < class FT >
222 std::istream& operator>>(std::istream& is, DirectionS3<FT>& p)
223 {
224  FT x, y, z;
225  switch(is.iword(IO::mode)) {
226  case IO::ASCII :
227  is >> x >> y >> z;
228  break;
229  case IO::BINARY :
230  read(is, x);
231  read(is, y);
232  read(is, z);
233  break;
234  default:
235  CGAL_kernel_assertion_msg(false,"Stream must be in ascii or binary mode");
236  // throw ios_base::failure("Stream must be in ascii or binary mode");
237  break;
238  }
239  p = DirectionS3<FT>(x, y, z);
240  return is;
241 }
242 #endif // CGAL_NO_ISTREAM_EXTRACT_DIRECTIONS3
243 
244 
245 
247 
248 #endif
const FT & hdy() const
Definition: DirectionS3.h:182
DirectionS3 transform(const Aff_transformationS3< FT > &t) const
Definition: DirectionS3.h:131
const FT & hdx() const
Definition: DirectionS3.h:175
const FT & dx() const
Definition: DirectionS3.h:155
static SURF_BEGIN_NAMESPACE double sign(double x)
const NT & d
DirectionS3 operator-() const
Definition: DirectionS3.h:138
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
const FT & delta(int i) const
Definition: DirectionS3.h:144
#define CGAL_kernel_assertion_msg(EX, MSG)
const FT & dz() const
Definition: DirectionS3.h:169
*********************************************************************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
const FT & dy() const
Definition: DirectionS3.h:162
FT hw() const
Definition: DirectionS3.h:195
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
VectorS3< FT > vector() const
Definition: DirectionS3.h:71
bool operator==(const DirectionS3< FT > &d) const
Definition: DirectionS3.h:105
DirectionS3(const FT &x, const FT &y, const FT &z)
Definition: DirectionS3.h:64
VectorS3< FT > to_vector() const
Definition: DirectionS3.h:124
NT dy
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)
bool operator!=(const DirectionS3< FT > &d) const
Definition: DirectionS3.h:118
#define CGAL_NTS
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
#define CGAL_kernel_precondition(EX)
const FT & hdz() const
Definition: DirectionS3.h:189