BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Cartesian/Direction_3.h
Go to the documentation of this file.
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/Direction_3.h $
00019 // $Id: Direction_3.h 49589 2009-05-26 07:54:52Z spion $
00020 // 
00021 //
00022 // Author(s)     : Andreas Fabri
00023 
00024 #ifndef CGAL_CARTESIAN_DIRECTION_3_H
00025 #define CGAL_CARTESIAN_DIRECTION_3_H
00026 
00027 #include <CGAL/array.h>
00028 #include <CGAL/Handle_for.h>
00029 
00030 CGAL_BEGIN_NAMESPACE
00031 
00032 template < class R_ >
00033 class DirectionC3
00034 {
00035   typedef typename R_::FT                   FT;
00036   typedef typename R_::Vector_3             Vector_3;
00037   typedef typename R_::Line_3               Line_3;
00038   typedef typename R_::Ray_3                Ray_3;
00039   typedef typename R_::Segment_3            Segment_3;
00040   typedef typename R_::Direction_3          Direction_3;
00041 
00042   typedef cpp0x::array<FT, 3>               Rep;
00043   typedef typename R_::template Handle<Rep>::type  Base;
00044 
00045   Base base;
00046 
00047 public:
00048 
00049   typedef R_                                R;
00050 
00051   DirectionC3() {}
00052 
00053   explicit DirectionC3(const Vector_3 &v)
00054     : base(CGAL::make_array(v.x(), v.y(), v.z())) {}
00055   // { *this = v.direction(); }
00056 
00057   explicit DirectionC3(const Line_3 &l)
00058   { *this = l.rep().direction(); }
00059 
00060   explicit DirectionC3(const Ray_3 &r)
00061   { *this = r.direction(); }
00062 
00063   explicit DirectionC3(const Segment_3 &s)
00064   { *this = s.direction(); }
00065 
00066   DirectionC3(const FT &x, const FT &y, const FT &z)
00067     : base(CGAL::make_array(x, y, z)) {}
00068 
00069   typename R::Boolean   operator==(const DirectionC3 &d) const;
00070   typename R::Boolean   operator!=(const DirectionC3 &d) const;
00071 
00072   Vector_3       to_vector() const;
00073   Vector_3       vector() const { return to_vector(); }
00074 
00075   const FT & dx() const
00076   {
00077       return get(base)[0];
00078   }
00079   const FT & dy() const
00080   {
00081       return get(base)[1];
00082   }
00083   const FT & dz() const
00084   {
00085       return get(base)[2];
00086   }
00087 
00088   const FT & hdx() const
00089   {
00090       return dx();
00091   }
00092   const FT & hdy() const
00093   {
00094       return dy();
00095   }
00096   const FT & hdz() const
00097   {
00098       return dz();
00099   }
00100   FT hw() const
00101   {
00102       return FT(1);
00103   }
00104 };
00105 
00106 template < class R >
00107 inline
00108 typename R::Boolean
00109 DirectionC3<R>::operator==(const DirectionC3<R> &d) const
00110 {
00111   if (CGAL::identical(base, d.base))
00112       return true;
00113   return equal_directionC3(dx(), dy(), dz(), d.dx(), d.dy(), d.dz());
00114 }
00115 
00116 template < class R >
00117 inline
00118 typename R::Boolean
00119 DirectionC3<R>::operator!=(const DirectionC3<R> &d) const
00120 {
00121   return !(*this == d);
00122 }
00123 
00124 template < class R >
00125 inline
00126 typename DirectionC3<R>::Vector_3
00127 DirectionC3<R>::to_vector() const
00128 {
00129   return Vector_3(dx(), dy(), dz());
00130 }
00131 
00132 CGAL_END_NAMESPACE
00133 
00134 #endif // CGAL_CARTESIAN_DIRECTION_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines