BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Homogeneous/basic_constructionsH3.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/basic_constructionsH3.h $
00019 // $Id: basic_constructionsH3.h 42811 2008-04-09 13:35:34Z spion $
00020 // 
00021 //
00022 // Author(s)     : Stefan Schirra
00023  
00024 
00025 #ifndef CGAL_BASIC_CONSTRUCTIONSH3_H
00026 #define CGAL_BASIC_CONSTRUCTIONSH3_H
00027 
00028 CGAL_BEGIN_NAMESPACE
00029 
00030 template <class R>
00031 typename R::Point_3
00032 _projection(const typename R::Point_3& p, const PlaneH3<R>& pl)
00033 {
00034   typedef typename R::RT RT;
00035   if ( pl.has_on(p) ) return p;
00036 
00037   RT A = pl.a();
00038   RT B = pl.b();
00039   RT C = pl.c();
00040   RT D = pl.d();
00041   RT phx = p.hx();
00042   RT phy = p.hy();
00043   RT phz = p.hz();
00044   RT phw = p.hw();
00045 
00046   RT num = A * phx  +  B * phy  +  C * phz  +  D * phw;
00047   RT den = A * A    +  B * B    +  C * C;
00048 
00049   return typename R::Point_3( num * A  -  den * phx,
00050                               num * B  -  den * phy,
00051                               num * C  -  den * phz,
00052                              -den );
00053 }
00054 
00055 template <class R>
00056 typename R::Point_3
00057 gp_linear_intersection(const PlaneH3<R> &f,
00058                        const PlaneH3<R> &g,
00059                        const PlaneH3<R> &h)
00060 {
00061   typedef typename R::RT RT;
00062   return typename R::Point_3(
00063                   determinant<RT>(-f.d(), f.b(), f.c(),
00064                                         -g.d(), g.b(), g.c(),
00065                                         -h.d(), h.b(), h.c()),
00066                   determinant<RT>( f.a(),-f.d(), f.c(),
00067                                          g.a(),-g.d(), g.c(),
00068                                          h.a(),-h.d(), h.c()),
00069                   determinant<RT>( f.a(), f.b(),-f.d(),
00070                                          g.a(), g.b(),-g.d(),
00071                                          h.a(), h.b(),-h.d()),
00072                   determinant<RT>( f.a(), f.b(), f.c(),
00073                                          g.a(), g.b(), g.c(),
00074                                          h.a(), h.b(), h.c()));
00075 }
00076 
00077 template <class R>
00078 CGAL_KERNEL_INLINE
00079 typename R::FT
00080 squared_distance( PointH3<R> const& p, PointH3<R> const& q)
00081 { return (p-q)*(p-q); }
00082 
00083 CGAL_END_NAMESPACE
00084 
00085 #endif // CGAL_BASIC_CONSTRUCTIONSH3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines