BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Nef_S2/Sphere_point.h
Go to the documentation of this file.
00001 // Copyright (c) 1997-2002  Max-Planck-Institute Saarbruecken (Germany).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under
00005 // the terms of the Q Public License version 1.0.
00006 // See the file LICENSE.QPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Nef_S2/include/CGAL/Nef_S2/Sphere_point.h $
00015 // $Id: Sphere_point.h 44480 2008-07-26 20:26:48Z hachenb $
00016 // 
00017 //
00018 // Author(s)     : Michael Seel  <seel@mpi-sb.mpg.de>
00019 
00020 #ifndef CGAL_SPHERE_POINT_H
00021 #define CGAL_SPHERE_POINT_H
00022 
00023 #include <CGAL/basic.h>
00024 #include <CGAL/Origin.h>
00025 
00026 CGAL_BEGIN_NAMESPACE
00027 
00028 /*{\Mtext \headerline{Restricted Spherical Geometry}
00029 
00030 We introduce geometric objects that are part of the
00031 spherical surface $S_2$ and operations on them. We define types
00032 |Sphere_point|, |Sphere_circle|, |Sphere_segment|, and
00033 |Sphere_direction|.  |Sphere_point|s are points on $S_2$,
00034 |Sphere_circle|s are oriented great circles of $S_2$,
00035 |Sphere_segment|s are oriented parts of |Sphere_circles| bounded by a
00036 pair of |Sphere_point|s, and |Sphere_direction|s are directions that
00037 are part of great circles (a direction is usually defined to be a
00038 vector without length, that floats around in its underlying space and
00039 can be used to specify a movement at any point of the underlying
00040 space; in our case we use directions only at points that are part of
00041 the great circle that underlies also the direction.)
00042 
00043 Note that we have to consider special geometric properties of the
00044 objects. For example two points that are part of a great circle define
00045 two |Sphere_segment|s, and two arbitrary |Sphere_segment|s can
00046 intersect in two points. 
00047 
00048 If we restrict our geometric objects to a so-called perfect hemisphere
00049 of $S_2$\footnote{A perfect hemisphere of $S_2$ is an open half-sphere
00050 plus an open half-circle in the boundary of the open half-sphere plus one
00051 endpoint of the half-circle.} then the restricted objects behave like
00052 in classical geometry, e.g., two points define exactly one segment,
00053 two segments intersect in at most one interior point
00054 (non-degenerately), or three non-cocircular sphere points can be
00055 qualified as being positively or negatively oriented.}*/
00056 
00057 /*{\Moptions print_title=yes }*/ 
00058 /*{\Manpage{Sphere_point}{R}{Points on the unit sphere}{p}}*/ 
00059  
00060 template <class R_> 
00061 class Sphere_point : public R_::Point_3 {
00062 
00063 /*{\Mdefinition An object |\Mvar| of type |\Mname| is a point on the
00064 surface of a unit sphere. Such points correspond to the nontrivial
00065 directions in space and similarly to the equivalence classes of all
00066 nontrivial vectors under normalization.}*/ 
00067 
00068 public:
00069 /*{\Mtypes 5}*/
00070 typedef R_ R;
00071 /*{\Mtypemember representation class.}*/
00072 typedef typename R_::FT FT;
00073 /*{\Xtypemember ring number type.}*/
00074 typedef typename R_::RT RT;
00075 /*{\Mtypemember field number type.}*/
00076 typedef Sphere_point<R>    Self;
00077 typedef typename R::Point_3     Base;
00078 typedef typename R::Vector_3    Vector_3;
00079 typedef typename R::Direction_3 Direction_3;
00080 
00081 /*{\Mcreation 5}*/
00082 Sphere_point() : Base() {}
00083 /*{\Mcreate creates some sphere point.}*/
00084 
00085 Sphere_point(int x, int y, int z) :
00086 Base(x,y,z,1) { CGAL_assertion(x!=0 || y!=0 || z!=0); }
00087 
00088 Sphere_point(const RT& x, const RT& y, const RT& z) :
00089 /*{\Mcreate creates a sphere point corresponding to the point of
00090 intersection of the ray starting at the origin in direction $(x,y,z)$
00091 and the surface of $S_2$.}*/
00092   Base(x,y,z,1) { CGAL_assertion(x!=0 || y!=0 || z!=0); }
00093 
00094 Sphere_point(const Base& p) : Base(p) {} 
00095 Sphere_point(const Vector_3& v) : Base(CGAL::ORIGIN+v) {} 
00096 Sphere_point(const Direction_3& d) : 
00097   Base(CGAL::ORIGIN+d.vector()) {} 
00098 
00099 /*{\Moperations 4 2}*/
00100 
00101 /*{\Mtext Access to the coordinates is provided by the following
00102 operations. Note that the vector $(x,y,z)$ is not normalized.}*/
00103 
00104 RT x() const { return ((Base*) this)->hx(); }
00105 /*{\Mop the $x$-coordinate.}*/
00106 RT y() const { return ((Base*) this)->hy(); }
00107 /*{\Mop the $y$-coordinate.}*/
00108 RT z() const { return ((Base*) this)->hz(); }
00109 /*{\Mop the $z$-coordinate.}*/
00110 
00111 bool operator==(const Sphere_point<R>& q) const 
00112 /*{\Mbinop Equality.}*/
00113 { return Direction_3(Base(*this)-ORIGIN)==
00114          Direction_3(q-ORIGIN); }
00115 
00116 bool operator!=(const Sphere_point<R>& q) const
00117 /*{\Mbinop Inequality.}*/
00118 { return !operator==(q); }
00119 
00120 Sphere_point<R> antipode() const 
00121 /*{\Mop returns the antipode of |\Mvar|.}*/
00122 { return ORIGIN + -(Base(*this)-ORIGIN); }
00123 
00124 }; // Sphere_point<R>
00125 
00126 template <typename R>
00127 typename R::Point_3 operator+
00128   (const typename R::Point_3& p, const Sphere_point<R>& q)
00129 { return p + (q-CGAL::ORIGIN); }
00130 
00131 CGAL_END_NAMESPACE
00132 #endif //CGAL_SPHERE_POINT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines