📄 planeh3.h
字号:
// Copyright (c) 1999 Utrecht University (The Netherlands),// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),// and Tel-Aviv University (Israel). All rights reserved.//// This file is part of CGAL (www.cgal.org); you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License as// published by the Free Software Foundation; version 2.1 of the License.// See the file LICENSE.LGPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h $// $Id: PlaneH3.h 33070 2006-08-06 16:06:39Z spion $// //// Author(s) : Stefan Schirra#ifndef CGAL_PLANEH3_H#define CGAL_PLANEH3_H#include <CGAL/Fourtuple.h>CGAL_BEGIN_NAMESPACEtemplate < class R_ >class PlaneH3{ typedef typename R_::RT RT; typedef typename R_::FT FT; typedef typename R_::Point_2 Point_2; typedef typename R_::Point_3 Point_3; typedef typename R_::Vector_3 Vector_3; typedef typename R_::Line_3 Line_3; typedef typename R_::Segment_3 Segment_3; typedef typename R_::Ray_3 Ray_3; typedef typename R_::Direction_3 Direction_3; typedef typename R_::Plane_3 Plane_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef Fourtuple<RT> Rep; typedef typename R_::template Handle<Rep>::type Base; Base base;public: typedef R_ R; PlaneH3() {} PlaneH3(const Point_3&, const Point_3&, const Point_3& ); PlaneH3(const RT& a, const RT& b, const RT& c, const RT& d ); PlaneH3(const Point_3&, const Ray_3& ); PlaneH3(const Point_3&, const Line_3& ); PlaneH3(const Point_3&, const Segment_3& ); PlaneH3(const Line_3&, const Point_3& ); PlaneH3(const Segment_3&, const Point_3& ); PlaneH3(const Ray_3&, const Point_3& ); PlaneH3(const Point_3&, const Direction_3& ); PlaneH3(const Point_3&, const Vector_3& ); PlaneH3(const Point_3&, const Direction_3&, const Direction_3& ); const RT & a() const; const RT & b() const; const RT & c() const; const RT & d() const; bool operator==( const PlaneH3<R>& ) const; bool operator!=( const PlaneH3<R>& ) const; Line_3 perpendicular_line(const Point_3& ) const; Plane_3 opposite() const; // plane with opposite orientation Point_3 projection(const Point_3& ) const; Point_3 point() const; // same point on the plane Direction_3 orthogonal_direction() const; Vector_3 orthogonal_vector() const; Oriented_side oriented_side(const Point_3 &p) const; bool has_on(const Point_3 &p) const; bool has_on(const Line_3 &p) const; bool has_on_positive_side(const Point_3&l) const; bool has_on_negative_side(const Point_3&l) const; bool is_degenerate() const; Aff_transformation_3 transform_to_2d() const; Point_2 to_2d(const Point_3& ) const; Point_3 to_3d(const Point_2& ) const; Vector_3 base1() const; Vector_3 base2() const;protected: Point_3 point1() const; // same point different from point() Point_3 point2() const; // same point different from point() // and point1() void new_rep(const Point_3 &p, const Point_3 &q, const Point_3 &r); void new_rep(const RT &a, const RT &b, const RT &c, const RT &d);};//// a() * X + b() * Y + c() * Z() + d() * W() == 0//// | X Y Z W |// | p.hx() p.hy() p.hz() p.hw() |// | q.hx() q.hy() q.hz() q.hw() |// | r.hx() r.hy() r.hz() r.hw() |//// Fourtuple<RT> ( a(), b(), c(), d() )template < class R >inlinevoidPlaneH3<R>::new_rep(const typename PlaneH3<R>::Point_3 &p, const typename PlaneH3<R>::Point_3 &q, const typename PlaneH3<R>::Point_3 &r){ RT phx = p.hx(); RT phy = p.hy(); RT phz = p.hz(); RT phw = p.hw(); RT qhx = q.hx(); RT qhy = q.hy(); RT qhz = q.hz(); RT qhw = q.hw(); RT rhx = r.hx(); RT rhy = r.hy(); RT rhz = r.hz(); RT rhw = r.hw(); base = Rep ( phy*( qhz*rhw - qhw*rhz ) - qhy*( phz*rhw - phw*rhz ) // * X + rhy*( phz*qhw - phw*qhz ), - phx*( qhz*rhw - qhw*rhz ) + qhx*( phz*rhw - phw*rhz ) // * Y - rhx*( phz*qhw - phw*qhz ), phx*( qhy*rhw - qhw*rhy ) - qhx*( phy*rhw - phw*rhy ) // * Z + rhx*( phy*qhw - phw*qhy ), - phx*( qhy*rhz - qhz*rhy ) + qhx*( phy*rhz - phz*rhy ) // * W - rhx*( phy*qhz - phz*qhy ) );}template < class R >inlinevoidPlaneH3<R>::new_rep(const RT &a, const RT &b, const RT &c, const RT &d){ base = Rep(a, b, c, d); }template < class R >inlineboolPlaneH3<R>::operator!=(const PlaneH3<R>& l) const{ return !(*this == l);}template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p, const typename PlaneH3<R>::Point_3& q, const typename PlaneH3<R>::Point_3& r){ new_rep(p,q,r); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const RT& a, const RT& b, const RT& c, const RT& d){ new_rep(a,b,c,d); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p , const typename PlaneH3<R>::Line_3& l){ new_rep(p, l.point(0), l.point(1) ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p, const typename PlaneH3<R>::Segment_3& s){ new_rep(p, s.source(), s.target() ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p , const typename PlaneH3<R>::Ray_3& r){ new_rep(p, r.start(), r.start() + r.direction().to_vector() ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Line_3& l , const typename PlaneH3<R>::Point_3& p){ new_rep(l.point(0), p, l.point(1) ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Segment_3& s, const typename PlaneH3<R>::Point_3& p){ new_rep(s.source(), p, s.target() ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Ray_3& r, const typename PlaneH3<R>::Point_3& p){ new_rep(r.start(), p, r.start() + r.direction().to_vector() ); }template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p, const typename PlaneH3<R>::Direction_3& d){ Vector_3 ov = d.to_vector(); new_rep( ov.hx()*p.hw(), ov.hy()*p.hw(), ov.hz()*p.hw(), -(ov.hx()*p.hx() + ov.hy()*p.hy() + ov.hz()*p.hz() ) );}template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p, const typename PlaneH3<R>::Vector_3& ov){ new_rep( ov.hx()*p.hw(), ov.hy()*p.hw(), ov.hz()*p.hw(), -(ov.hx()*p.hx() + ov.hy()*p.hy() + ov.hz()*p.hz() ) );}template < class R >CGAL_KERNEL_INLINEPlaneH3<R>::PlaneH3(const typename PlaneH3<R>::Point_3& p, const typename PlaneH3<R>::Direction_3& d1, const typename PlaneH3<R>::Direction_3& d2){ new_rep( p, p + d1.to_vector(), p + d2.to_vector() ); }template < class R >inlineconst typename PlaneH3<R>::RT &PlaneH3<R>::a() const{ return get(base).e0; }template < class R >inlineconst typename PlaneH3<R>::RT &PlaneH3<R>::b() const{ return get(base).e1; }template < class R >inlineconst typename PlaneH3<R>::RT &PlaneH3<R>::c() const{ return get(base).e2; }template < class R >inlineconst typename PlaneH3<R>::RT &
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -