Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RayS3.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/RayS3.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_RAYS3_H
52 #define CGAL_RAYS3_H
53 
55 
57 
58 template < class FT >
59 class RayS3
60 {
61 public:
62  RayS3() {}
63  RayS3(const PointS3<FT>& sp, const PointS3<FT>& secondp);
64  RayS3(const PointS3<FT>& sp, const DirectionS3<FT>& d);
65 
66  bool operator==(const RayS3<FT>& r) const;
67  bool operator!=(const RayS3<FT>& r) const;
68 
69  PointS3<FT> start() const;
70  PointS3<FT> source() const;
71  PointS3<FT> second_point() const;
72  PointS3<FT> point(int i) const;
73 
74  DirectionS3<FT> direction() const;
76  RayS3 opposite() const;
77 
79 
80  bool is_degenerate() const;
81  bool has_on(const PointS3<FT>& p) const;
82  bool collinear_has_on(const PointS3<FT>& p) const;
83 
84 // private:
87 };
88 
89 
90 template < class FT >
91 RayS3<FT>::RayS3(const PointS3<FT>& sp, const PointS3<FT>& secondp)
92 {
93  e0 = sp;
94  e1 = secondp;
95 }
96 
97 
98 template < class FT >
100 {
101  e0 = sp;
102  e1 = sp + d.vector();
103 }
104 
105 
106 template < class FT >
107 inline
108 bool
110 { return (source() == r.source()) && (direction() == r.direction()); }
111 
112 
113 template < class FT >
114 inline
115 bool
117 { return !(*this == r); }
118 
119 
120 template < class FT >
123 { return e0; }
124 
125 
126 template < class FT >
129 { return e0; }
130 
131 template < class FT >
134 { return e1; }
135 
136 
137 template < class FT >
139 RayS3<FT>::point(int i) const
140 {
141  CGAL_kernel_precondition( i >= 0 );
142  if (i == 0)
143  return e0;
144 
145  if (i == 1)
146  return e1;
147 
148  return source() + FT(i) * (second_point() - source());
149 }
150 
151 
152 template < class FT >
153 inline
156 { return DirectionS3<FT>( second_point() - source() ); }
157 
158 
159 template < class FT >
160 inline
163 { return LineS3<FT>(*this); }
164 
165 
166 template < class FT >
167 inline
168 RayS3<FT>
170 { return RayS3<FT>( source(), - direction() ); }
171 
172 
173 template < class FT >
174 inline
175 RayS3<FT>
177 { return RayS3<FT>(t.transform(source()), t.transform(second_point())); }
178 
179 
180 template < class FT >
181 bool
183 {
184  return (p == source()) ||
185  ( collinear(source(), p, second_point())
186  && ( DirectionS3<FT>(p - source()) == direction() ));
187 }
188 
189 
190 template < class FT >
191 inline
192 bool
194 { return source() == second_point(); }
195 
196 
197 template < class FT >
198 inline
199 bool
201 {
202  CGAL_kernel_exactness_precondition( collinear(source(), p, second_point()) );
203 
204  Comparison_result cx = compare_x(source(), second_point());
205  if (cx != EQUAL)
206  return cx != compare_x(p, source());
207 
208  Comparison_result cy = compare_y(source(), second_point());
209  if (cy != EQUAL)
210  return cy != compare_y(p, source());
211 
212  Comparison_result cz = compare_z(source(), second_point());
213  if (cz != EQUAL)
214  return cz != compare_z(p, source());
215 
216  return true; // p == source()
217 }
218 
219 
220 #ifndef CGAL_NO_OSTREAM_INSERT_RAYS3
221 template < class FT >
222 std::ostream&
223 operator<<(std::ostream& os, const RayS3<FT>& r)
224 {
225  switch(os.iword(IO::mode))
226  {
227  case IO::ASCII :
228  return os << r.start() << ' ' << r.direction();
229  case IO::BINARY :
230  return os<< r.start() << r.direction();
231  default:
232  return os << "RayS3(" << r.start() << ", " << r.direction() << ")";
233  }
234 }
235 #endif // CGAL_NO_OSTREAM_INSERT_RAYS3
236 
237 #ifndef CGAL_NO_ISTREAM_EXTRACT_RAYS3
238 template < class FT >
239 std::istream&
240 operator>>(std::istream& is, RayS3<FT>& r)
241 {
242  PointS3<FT> p;
244 
245  is >> p >> d;
246 
247  r = RayS3<FT>(p, d);
248  return is;
249 }
250 #endif // CGAL_NO_ISTREAM_EXTRACT_RAYS3
251 
252 
254 
255 #endif
PointS3< FT > e0
Definition: RayS3.h:85
PointS3< FT > source() const
Definition: RayS3.h:128
RayS3 transform(const Aff_transformationS3< FT > &t) const
Definition: RayS3.h:176
Comparison_result compare_y(const Point_2< R > &p, const Point_2< R > &q)
const NT & d
RayS3()
Definition: RayS3.h:62
bool operator==(const RayS3< FT > &r) const
Definition: RayS3.h:109
RayS3 opposite() const
Definition: RayS3.h:169
bool operator!=(const RayS3< FT > &r) const
Definition: RayS3.h:116
Definition: io.h:64
Comparison_result compare_x(const Point_2< R > &p, const Point_2< R > &q)
bool has_on(const PointS3< FT > &p) const
Definition: RayS3.h:182
bool collinear(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)
DirectionS3< FT > direction() const
Definition: RayS3.h:155
blockLoc i
Definition: read.cpp:79
PointS3< FT > transform(const PointS3< FT > &p) const
PointS3< FT > second_point() const
Definition: RayS3.h:133
static int mode
Definition: io.h:63
Definition: io.h:64
VectorS3< FT > vector() const
Definition: DirectionS3.h:71
#define CGAL_kernel_exactness_precondition(EX)
bool is_degenerate() const
Definition: RayS3.h:193
PointS3< FT > point(int i) const
Definition: RayS3.h:139
Comparison_result
Definition: enum.h:94
Definition: enum.h:97
PointS3< FT > e1
Definition: RayS3.h:86
Definition: RayS3.h:59
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
Comparison_result compare_z(const PointS3< FT > &p, const PointS3< FT > &q)
PointS3< FT > start() const
Definition: RayS3.h:122
bool collinear_has_on(const PointS3< FT > &p) const
Definition: RayS3.h:200
LineS3< FT > supporting_line() const
Definition: RayS3.h:162
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
#define CGAL_kernel_precondition(EX)
Definition: LineS3.h:59