BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Homogeneous/PointH3.h
Go to the documentation of this file.
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/PointH3.h $
00019 // $Id: PointH3.h 42834 2008-04-10 14:41:35Z spion $
00020 //
00021 //
00022 // Author(s)     : Stefan Schirra
00023 
00024 #ifndef CGAL_HOMOGENEOUS_POINT_3_H
00025 #define CGAL_HOMOGENEOUS_POINT_3_H
00026 
00027 #include <CGAL/Origin.h>
00028 #include <boost/utility/enable_if.hpp>
00029 #include <boost/utility.hpp>
00030 #include <boost/mpl/and.hpp>
00031 #include <boost/mpl/logical.hpp>
00032 
00033 CGAL_BEGIN_NAMESPACE
00034 
00035 template < class R_ >
00036 class PointH3
00037 {
00038    typedef typename R_::RT                   RT;
00039    typedef typename R_::FT                   FT;
00040    typedef typename R_::Vector_3             Vector_3;
00041    typedef typename R_::Point_3              Point_3;
00042    typedef typename R_::Direction_3          Direction_3;
00043    typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00044 
00045    typedef Rational_traits<FT>  Rat_traits;
00046 
00047    // Reference-counting is handled in Vector_3.
00048    Vector_3 base;
00049 
00050 public:
00051 
00052    typedef typename Vector_3::Cartesian_const_iterator Cartesian_const_iterator;
00053    typedef R_                 R;
00054 
00055   PointH3() {}
00056 
00057   PointH3(const Origin &)
00058     : base(NULL_VECTOR) {}
00059 
00060   template < typename Tx, typename Ty, typename Tz >
00061   PointH3(const Tx & x, const Ty & y, const Tz & z,
00062           typename boost::enable_if< boost::mpl::and_< boost::mpl::and_< boost::is_convertible<Tx, RT>,
00063                                                                          boost::is_convertible<Ty, RT> >,
00064                                                        boost::is_convertible<Tz, RT> > >::type* = 0)
00065     : base(x, y, z) {}
00066 
00067   PointH3(const FT& x, const FT& y, const FT& z)
00068     : base(x, y, z) {}
00069 
00070   PointH3(const RT& x, const RT& y, const RT& z, const RT& w)
00071     : base(x, y, z, w) {}
00072 
00073   FT    x()  const;
00074   FT    y()  const;
00075   FT    z()  const;
00076   const RT & hx() const;
00077   const RT & hy() const;
00078   const RT & hz() const;
00079   const RT & hw() const;
00080   const RT & homogeneous(int i) const;
00081   FT    cartesian(int i) const;
00082   FT    operator[](int i) const;
00083 
00084 
00085   Cartesian_const_iterator cartesian_begin() const
00086   {
00087     return base.cartesian_begin();
00088   }
00089 
00090   Cartesian_const_iterator cartesian_end() const
00091   {
00092     return base.cartesian_end();
00093   }
00094 
00095   int   dimension() const;
00096 
00097   Direction_3 direction() const;
00098   Point_3     transform( const Aff_transformation_3 & t) const;
00099 
00100   bool  operator==( const PointH3<R>& p) const;
00101   bool  operator!=( const PointH3<R>& p) const;
00102 };
00103 
00104 
00105 template < class R >
00106 inline
00107 const typename PointH3<R>::RT &
00108 PointH3<R>::hx() const
00109 { return base.hx(); }
00110 
00111 template < class R >
00112 inline
00113 const typename PointH3<R>::RT &
00114 PointH3<R>::hy() const
00115 { return base.hy(); }
00116 
00117 template < class R >
00118 inline
00119 const typename PointH3<R>::RT &
00120 PointH3<R>::hz() const
00121 { return base.hz(); }
00122 
00123 template < class R >
00124 inline
00125 const typename PointH3<R>::RT &
00126 PointH3<R>::hw() const
00127 { return base.hw(); }
00128 
00129 template < class R >
00130 inline
00131 typename PointH3<R>::FT
00132 PointH3<R>::x()  const
00133 { return base.x(); }
00134 
00135 template < class R >
00136 inline
00137 typename PointH3<R>::FT
00138 PointH3<R>::y()  const
00139 { return base.y(); }
00140 
00141 template < class R >
00142 inline
00143 typename PointH3<R>::FT
00144 PointH3<R>::z()  const
00145 { return base.z(); }
00146 
00147 template < class R >
00148 inline
00149 int
00150 PointH3<R>::dimension() const
00151 { return base.dimension(); }
00152 
00153 template < class R >
00154 inline
00155 typename PointH3<R>::FT
00156 PointH3<R>::cartesian(int i) const
00157 {
00158   return base.cartesian(i);
00159 }
00160 
00161 template < class R >
00162 inline
00163 const typename PointH3<R>::RT &
00164 PointH3<R>::homogeneous(int i) const
00165 {
00166   return base.homogeneous(i);
00167 }
00168 
00169 template < class R >
00170 inline
00171 typename PointH3<R>::FT
00172 PointH3<R>::operator[](int i) const
00173 {
00174   return base[i];
00175 }
00176 
00177 template < class R >
00178 inline
00179 typename PointH3<R>::Direction_3
00180 PointH3<R>::direction() const
00181 { return Direction_3(*this); }
00182 
00183 template < class R >
00184 inline
00185 bool
00186 PointH3<R>::operator==( const PointH3<R> & p) const
00187 {
00188   return base == p.base;
00189 }
00190 
00191 template < class R >
00192 inline
00193 bool
00194 PointH3<R>::operator!=( const PointH3<R> & p) const
00195 { return !(*this == p); }
00196 
00197 
00198 template < class R >
00199 inline
00200 typename R::Point_3
00201 PointH3<R>::transform(const typename PointH3<R>::Aff_transformation_3& t) const
00202 { return t.transform(static_cast<const Point_3&>(*this)); }
00203 
00204 CGAL_END_NAMESPACE
00205 
00206 #endif // CGAL_HOMOGENEOUS_POINT_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines