Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LineS3.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/LineS3.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_LINES3_H
52 #define CGAL_LINES3_H
53 
55 
57 
58 template < class FT >
59 class LineS3
60 {
61 public:
62  LineS3() {}
63  LineS3(const PointS3<FT>& p,
64  const PointS3<FT>& q);
65  LineS3(const SegmentS3<FT>& s);
66  LineS3(const RayS3<FT>& r);
67  LineS3(const PointS3<FT>& p,
68  const DirectionS3<FT>& d);
69 
70  bool operator==(const LineS3<FT>& l) const;
71  bool operator!=(const LineS3<FT>& l) const;
72 
74  LineS3<FT> opposite() const;
75 
76  PointS3<FT> point() const;
77  PointS3<FT> point(int i) const;
78 
79  PointS3<FT> projection(const PointS3<FT>& p) const;
80 
81  DirectionS3<FT> direction() const;
82 
83  bool has_on(const PointS3<FT>& p) const;
84  bool is_degenerate() const;
85 
87 
88 
89 // private:
90  void new_rep(const PointS3<FT>& p,
91  const VectorS3<FT>& v);
92 
95 
96 };
97 
98 
99 template < class FT >
100 inline
101 void
103 {
104  e0 = p;
105  e1 = ORIGIN + v;
106 }
107 
108 
110 
114 
116 
117 template < class FT >
119 { new_rep(p, q - p); }
120 
121 template < class FT >
123 { new_rep(s.start(), s.end() - s.start()); }
124 
125 template < class FT >
127 { new_rep(r.start(), r.second_point() - r.start()); }
128 
129 template < class FT >
131 { new_rep(p, d.vector()); }
132 
133 template < class FT >
134 bool LineS3<FT>::operator==(const LineS3<FT>& l) const
135 { return has_on(l.point()) && (direction() == l.direction()); }
136 
137 template < class FT >
138 inline
139 bool
141 { return !(*this == l); }
142 
143 template < class FT >
146 { return e0; }
147 
148 template < class FT >
151 { return (e1 - ORIGIN).direction(); }
152 
153 
154 template < class FT >
157 { return PointS3<FT>(point() + FT(i) * (e1 - ORIGIN)); }
158 
159 template < class FT >
162 { return PlaneS3<FT>(p, direction().vector()); }
163 
164 template < class FT >
165 LineS3<FT>
167 { return LineS3<FT>(point(), -direction()); }
168 
169 template < class FT >
172 {
173  return point() + ( ((direction().vector() * (p - point())) /
174  (direction().vector() * direction().vector()))
175  * direction().vector() );
176 }
177 
178 template < class FT >
179 bool
181 { return collinear(point(), point()+direction().vector(), p); }
182 
183 
184 template < class FT >
185 bool
187 { return direction() == DirectionS3<FT>(0,0,0); }
188 
189 
190 template < class FT >
191 inline
192 LineS3<FT>
194 { return LineS3<FT>( t.transform(point()), t.transform(direction())); }
195 
196 
197 #ifndef CGAL_NO_OSTREAM_INSERT_LINES3
198 template < class FT >
199 std::ostream&
200 operator<<(std::ostream& os, const LineS3<FT>& l)
201 {
202  switch(os.iword(IO::mode))
203  {
204  case IO::ASCII :
205  return os << l.point(0) << ' ' << l.point(1);
206  case IO::BINARY :
207  return os << l.point(0) << l.point(1);
208  default:
209  return os << "LineS3(" << l.point(0) << ", " << l.point(1) << ")";
210  }
211 }
212 #endif // CGAL_NO_OSTREAM_INSERT_LINES3
213 
214 #ifndef CGAL_NO_ISTREAM_EXTRACT_LINES3
215 template < class FT >
216 std::istream&
217 operator>>(std::istream& is, LineS3<FT>& l)
218 {
219  PointS3<FT> p, q;
220  is >> p >> q;
221  l = LineS3<FT>(p, q);
222  return is;
223 }
224 #endif // CGAL_NO_ISTREAM_EXTRACT_LINES3
225 
226 
228 
229 #endif // CGAL_LINES3_H
bool is_degenerate() const
Definition: LineS3.h:186
const NT & d
PointS3< FT > e0
Definition: LineS3.h:93
void new_rep(const PointS3< FT > &p, const VectorS3< FT > &v)
Definition: LineS3.h:102
double s
Definition: blastest.C:80
PointS3< FT > start() const
Definition: SegmentS3.h:115
LineS3()
Definition: LineS3.h:62
PointS3< FT > projection(const PointS3< FT > &p) const
Definition: LineS3.h:171
bool has_on(const PointS3< FT > &p) const
Definition: LineS3.h:180
LineS3< FT > opposite() const
Definition: LineS3.h:166
*********************************************************************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
bool collinear(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)
PointS3< FT > end() const
Definition: SegmentS3.h:120
PlaneS3< FT > perpendicular_plane(const PointS3< FT > &p) const
Definition: LineS3.h:161
blockLoc i
Definition: read.cpp:79
PointS3< FT > point() const
Definition: LineS3.h:145
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
LineS3< FT > transform(const Aff_transformationS3< FT > &t) const
Definition: LineS3.h:193
Origin ORIGIN
Definition: Origin.C:61
NT q
Definition: RayS3.h:59
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
DirectionS3< FT > direction() const
Definition: LineS3.h:150
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
bool operator==(const LineS3< FT > &l) const
Definition: LineS3.h:134
bool operator!=(const LineS3< FT > &l) const
Definition: LineS3.h:140
PointS3< FT > start() const
Definition: RayS3.h:122
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
Definition: LineS3.h:59
PointS3< FT > e1
Definition: LineS3.h:94