BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Homogeneous/basic_constructionsH2.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_constructionsH2.h $
00019 // $Id: basic_constructionsH2.h 28567 2006-02-16 14:30:13Z lsaboret $
00020 // 
00021 //
00022 // Author(s)     : Sven Schoenherr
00023 //                 Stefan Schirra
00024  
00025 
00026 #ifndef CGAL_BASIC_CONSTRUCTIONSH2_H
00027 #define CGAL_BASIC_CONSTRUCTIONSH2_H
00028 
00029 #include <CGAL/Homogeneous/PointH2.h>
00030 #include <CGAL/Homogeneous/LineH2.h>
00031 
00032 CGAL_BEGIN_NAMESPACE
00033 
00034 template <class R>
00035 CGAL_KERNEL_MEDIUM_INLINE
00036 typename R::Point_2
00037 gp_linear_intersection(const LineH2<R>& l1, const LineH2<R>& l2)
00038 {
00039   return typename R::Point_2( l1.b()*l2.c() - l2.b()*l1.c(),
00040                               l2.a()*l1.c() - l1.a()*l2.c(),
00041                               l1.a()*l2.b() - l2.a()*l1.b() );
00042 }
00043 
00044 template <class R>
00045 CGAL_KERNEL_MEDIUM_INLINE
00046 typename R::FT
00047 squared_distance( const PointH2<R>& p, const PointH2<R>& q )
00048 {
00049   typedef typename R::RT RT;
00050   typedef typename R::FT FT;
00051 
00052   const RT & phx = p.hx();
00053   const RT & phy = p.hy();
00054   const RT & phw = p.hw();
00055   const RT & qhx = q.hx();
00056   const RT & qhy = q.hy();
00057   const RT & qhw = q.hw();
00058 
00059   RT sq_dist_numerator =
00060           phx * phx * qhw * qhw
00061     - RT(2) * phx * qhx * phw * qhw
00062     +     qhx * qhx * phw * phw
00063 
00064     +     phy * phy * qhw * qhw
00065     - RT(2) * phy * qhy * phw * qhw
00066     +     qhy * qhy * phw * phw ;
00067 
00068   RT sq_dist_denominator = qhw * qhw * phw * phw ;
00069 
00070   return FT( sq_dist_numerator ) / FT( sq_dist_denominator );
00071 }
00072 
00073 CGAL_END_NAMESPACE
00074 
00075 #endif // CGAL_BASIC_CONSTRUCTIONSH2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines