BWAPI
|
00001 // Copyright (c) 2000 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/Cartesian_kernel/include/CGAL/Cartesian/Line_3.h $ 00019 // $Id: Line_3.h 49589 2009-05-26 07:54:52Z spion $ 00020 // 00021 // 00022 // Author(s) : Andreas Fabri 00023 00024 #ifndef CGAL_CARTESIAN_LINE_3_H 00025 #define CGAL_CARTESIAN_LINE_3_H 00026 00027 #include <utility> 00028 #include <CGAL/Handle_for.h> 00029 00030 CGAL_BEGIN_NAMESPACE 00031 00032 template < class R_ > 00033 class LineC3 00034 { 00035 typedef typename R_::RT RT; 00036 typedef typename R_::Point_3 Point_3; 00037 typedef typename R_::Vector_3 Vector_3; 00038 typedef typename R_::Direction_3 Direction_3; 00039 typedef typename R_::Plane_3 Plane_3; 00040 typedef typename R_::Ray_3 Ray_3; 00041 typedef typename R_::Line_3 Line_3; 00042 typedef typename R_::Segment_3 Segment_3; 00043 00044 typedef std::pair<Point_3, Vector_3> Rep; 00045 typedef typename R_::template Handle<Rep>::type Base; 00046 00047 Base base; 00048 00049 public: 00050 typedef R_ R; 00051 00052 LineC3() {} 00053 00054 LineC3(const Point_3 &p, const Point_3 &q) 00055 { *this = R().construct_line_3_object()(p, q); } 00056 00057 explicit LineC3(const Segment_3 &s) 00058 { *this = R().construct_line_3_object()(s); } 00059 00060 explicit LineC3(const Ray_3 &r) 00061 { *this = R().construct_line_3_object()(r); } 00062 00063 LineC3(const Point_3 &p, const Vector_3 &v) 00064 : base(p, v) {} 00065 00066 LineC3(const Point_3 &p, const Direction_3 &d) 00067 { *this = R().construct_line_3_object()(p, d); } 00068 00069 bool operator==(const LineC3 &l) const; 00070 bool operator!=(const LineC3 &l) const; 00071 00072 Plane_3 perpendicular_plane(const Point_3 &p) const; 00073 Line_3 opposite() const; 00074 00075 const Point_3 & point() const 00076 { 00077 return get(base).first; 00078 } 00079 00080 const Vector_3 & to_vector() const 00081 { 00082 return get(base).second; 00083 } 00084 00085 Direction_3 direction() const 00086 { 00087 return Direction_3(to_vector()); 00088 } 00089 00090 Point_3 point(int i) const; 00091 00092 bool has_on(const Point_3 &p) const; 00093 bool is_degenerate() const; 00094 }; 00095 00096 template < class R > 00097 inline 00098 bool 00099 LineC3<R>::operator==(const LineC3<R> &l) const 00100 { 00101 if (CGAL::identical(base, l.base)) 00102 return true; 00103 return has_on(l.point()) && (direction() == l.direction()); 00104 } 00105 00106 template < class R > 00107 inline 00108 bool 00109 LineC3<R>::operator!=(const LineC3<R> &l) const 00110 { 00111 return !(*this == l); 00112 } 00113 00114 template < class R > 00115 inline 00116 typename LineC3<R>::Point_3 00117 LineC3<R>::point(int i) const 00118 { return point() + to_vector()*RT(i); } 00119 00120 template < class R > 00121 inline 00122 typename LineC3<R>::Plane_3 00123 LineC3<R>:: 00124 perpendicular_plane(const typename LineC3<R>::Point_3 &p) const 00125 { 00126 return Plane_3(p, to_vector()); 00127 } 00128 00129 template < class R > 00130 inline 00131 typename LineC3<R>::Line_3 00132 LineC3<R>::opposite() const 00133 { 00134 return Line_3(point(), -to_vector()); 00135 } 00136 00137 template < class R > 00138 inline 00139 bool 00140 LineC3<R>:: 00141 has_on(const typename LineC3<R>::Point_3 &p) const 00142 { 00143 return collinear(point(), point()+to_vector(), p); 00144 } 00145 00146 template < class R > 00147 inline 00148 bool 00149 LineC3<R>::is_degenerate() const 00150 { 00151 return to_vector() == NULL_VECTOR; 00152 } 00153 00154 CGAL_END_NAMESPACE 00155 00156 #endif // CGAL_CARTESIAN_LINE_3_H