BWAPI
|
00001 // Copyright (c) 1999 Utrecht University (The Netherlands), 00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), 00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg 00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), 00005 // and Tel-Aviv University (Israel). All rights reserved. 00006 // 00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public License as 00009 // published by the Free Software Foundation; version 2.1 of the License. 00010 // See the file LICENSE.LGPL distributed with CGAL. 00011 // 00012 // Licensees holding a valid commercial license may use this file in 00013 // accordance with the commercial license agreement provided with the software. 00014 // 00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 // 00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Homogeneous_kernel/include/CGAL/Homogeneous/RayH3.h $ 00019 // $Id: RayH3.h 33066 2006-08-06 15:45:55Z spion $ 00020 // 00021 // 00022 // Author(s) : Stefan Schirra 00023 00024 #ifndef CGAL_RAYH3_H 00025 #define CGAL_RAYH3_H 00026 00027 #include <utility> 00028 00029 CGAL_BEGIN_NAMESPACE 00030 00031 template < class R_ > 00032 class RayH3 00033 { 00034 typedef typename R_::RT RT; 00035 typedef typename R_::FT FT; 00036 typedef typename R_::Point_3 Point_3; 00037 typedef typename R_::Line_3 Line_3; 00038 typedef typename R_::Direction_3 Direction_3; 00039 typedef typename R_::Vector_3 Vector_3; 00040 00041 typedef std::pair<Point_3, Vector_3> Rep; 00042 typedef typename R_::template Handle<Rep>::type Base; 00043 00044 Base base; 00045 00046 public: 00047 typedef R_ R; 00048 00049 RayH3() {} 00050 00051 RayH3( const Point_3& sp, const Point_3& secondp) 00052 : base(sp, secondp-sp) {} 00053 00054 RayH3( const Point_3& sp, const Vector_3& v) 00055 : base(sp, v) {} 00056 00057 RayH3( const Point_3& sp, const Direction_3& d) 00058 : base(sp, d.to_vector()) {} 00059 00060 RayH3( const Point_3& sp, const Line_3& l) 00061 : base(sp, l.to_vector()) {} 00062 00063 const Point_3 & start() const; 00064 const Point_3 & source() const; 00065 Point_3 second_point() const; 00066 Point_3 point(int i) const; 00067 Direction_3 direction() const; 00068 const Vector_3 & to_vector() const; 00069 Line_3 supporting_line() const; 00070 RayH3<R> opposite() const; 00071 bool has_on(const Point_3& p) const; 00072 bool collinear_has_on(const Point_3 &p) const; 00073 bool is_degenerate() const; 00074 00075 bool operator==(const RayH3<R>& r) const; 00076 bool operator!=(const RayH3<R>& r) const; 00077 }; 00078 00079 template < class R > 00080 inline 00081 const typename RayH3<R>::Point_3 & 00082 RayH3<R>::source() const 00083 { return get(base).first; } 00084 00085 template < class R > 00086 inline 00087 const typename RayH3<R>::Point_3 & 00088 RayH3<R>::start() const 00089 { return get(base).first; } 00090 00091 template < class R > 00092 inline 00093 const typename RayH3<R>::Vector_3 & 00094 RayH3<R>::to_vector() const 00095 { 00096 return get(base).second; 00097 } 00098 00099 template < class R > 00100 inline 00101 typename RayH3<R>::Direction_3 00102 RayH3<R>::direction() const 00103 { 00104 return to_vector().direction(); 00105 } 00106 00107 template < class R > 00108 CGAL_KERNEL_INLINE 00109 typename RayH3<R>::Point_3 00110 RayH3<R>::second_point() const 00111 { return start() + to_vector(); } 00112 00113 template < class R > 00114 CGAL_KERNEL_INLINE 00115 typename RayH3<R>::Point_3 00116 RayH3<R>::point(int i) const 00117 { 00118 CGAL_kernel_precondition( i >= 0 ); 00119 return start() + RT(i)*to_vector(); 00120 } 00121 00122 template < class R > 00123 CGAL_KERNEL_INLINE 00124 typename RayH3<R>::Line_3 00125 RayH3<R>::supporting_line() const 00126 { 00127 CGAL_kernel_precondition( !is_degenerate() ); 00128 return Line_3(start(), second_point() ); 00129 } 00130 00131 template < class R > 00132 CGAL_KERNEL_INLINE 00133 RayH3<R> 00134 RayH3<R>::opposite() const 00135 { return RayH3<R>( start(), - direction() ); } 00136 00137 00138 template < class R > 00139 CGAL_KERNEL_INLINE 00140 bool 00141 RayH3<R>::has_on(const typename RayH3<R>::Point_3 &p) const 00142 { 00143 return ( ( p == start() ) 00144 ||( Direction_3(p - start()) == direction() ) ); 00145 } 00146 00147 template < class R > 00148 inline /* XXX */ 00149 bool 00150 RayH3<R>::collinear_has_on(const typename RayH3<R>::Point_3 &p) const 00151 { return has_on(p); } 00152 00153 template < class R > 00154 inline 00155 bool 00156 RayH3<R>::is_degenerate() const 00157 { return to_vector() == NULL_VECTOR; } 00158 00159 template < class R > 00160 CGAL_KERNEL_INLINE 00161 bool 00162 RayH3<R>::operator==(const RayH3<R>& r) const 00163 { return ( (start() == r.start() )&&( direction() == r.direction() ) ); } 00164 00165 template < class R > 00166 CGAL_KERNEL_INLINE 00167 bool 00168 RayH3<R>::operator!=( const RayH3<R>& r) const 00169 { return !operator==(r); } 00170 00171 CGAL_END_NAMESPACE 00172 00173 #endif // CGAL_RAYH3_H