/usr/include/CGAL/Kernel_d/DirectionHd.h is in libcgal-dev 4.7-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | // Copyright (c) 2000,2001
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// 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; either version 3 of the License,
// or (at your option) any later version.
//
// 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$
// $Id$
//
//
// Author(s) : Michael Seel
#ifndef CGAL_DIRECTIONHD_H
#define CGAL_DIRECTIONHD_H
#include <CGAL/basic.h>
#include <CGAL/Quotient.h>
#include <CGAL/Kernel_d/Tuple_d.h>
#include <CGAL/Kernel_d/PointHd.h>
#include <CGAL/Kernel_d/VectorHd.h>
#include <CGAL/Kernel_d/Aff_transformationHd.h>
namespace CGAL {
template <class RT, class LA> class DirectionHd;
template <class RT, class LA>
std::istream& operator>>(std::istream&, DirectionHd<RT,LA>&);
template <class RT, class LA>
std::ostream& operator<<(std::ostream&, const DirectionHd<RT,LA>&);
/*{\Manpage{Direction_d}{R}{Directions in d-space}{dir}}*/
/*{\Msubst
Hd<RT,LA>#_d<R>
VectorHd#Vector_d
DirectionHd#Direction_d
Quotient<RT>#FT
}*/
template <class _RT, class _LA>
class DirectionHd : public Handle_for< Tuple_d<_RT,_LA> > {
typedef Tuple_d<_RT,_LA> Tuple;
typedef Handle_for<Tuple> Base;
typedef DirectionHd<_RT,_LA> Self;
using Base::ptr;
/*{\Mdefinition
A |DirectionHd| is a vector in the $d$-dimensional vector space
where we forget about its length. We represent directions in
$d$-dimensional space as a tuple $(h_0,\ldots,h_d)$ of variables of
type |RT| which we call the homogeneous coordinates of the
direction. The coordinate $h_d$ must be positive. The Cartesian
coordinates of a direction are $c_i = h_i/h_d$ for $0 \le i < d$,
which are of type |Quotient<RT>|. Two directions are equal if their
Cartesian coordinates are positive multiples of each other. Directions
are in one-to-one correspondence to points on the unit sphere.}*/
const typename _LA::Vector& vector_rep() const { return ptr()->v; }
_RT& entry(int i) { return ptr()->v[i]; }
const _RT& entry(int i) const { return ptr()->v[i]; }
void invert_rep() { ptr()->invert(); }
public:
/*{\Mtypes 4}*/
typedef _RT RT;
/*{\Mtypemember the ring type.}*/
typedef Quotient<_RT> FT;
/*{\Mtypemember the field type.}*/
typedef _LA LA;
/*{\Mtypemember the linear algebra layer.}*/
typedef typename Tuple::const_iterator Delta_const_iterator;
/*{\Mtypemember a read-only iterator for the deltas of |\Mvar|.}*/
class Base_direction {};
/*{\Mtypemember construction tag.}*/
friend class VectorHd<RT,LA>;
/*{\Mcreation 4}*/
DirectionHd(int d = 0) : Base( Tuple(d+1) )
/*{\Mcreate introduces a variable |\Mvar| of type |DirectionHd<RT,LA>|
initialized to some direction in $d$-dimensional space.}*/
{ if (d>0) entry(d) = 1; }
DirectionHd(const VectorHd<RT,LA>& v);
/*{\Mcreate introduces a variable |\Mvar| of type |DirectionHd<RT,LA>|
initialized to the direction of |v|.}*/
template <class InputIterator>
DirectionHd(int d, InputIterator first, InputIterator last) :
Base( Tuple(d+1,first,last,1) ) {}
/*{\Mcreate introduces a variable |\Mvar| of type |\Mname| in dimension |d|
with representation tuple |set [first,last)|. \precond |d| is
nonnegative, |[first,last)| has |d| elements and the value type of
|InputIterator| is |RT|.}*/
DirectionHd(int d, Base_direction, int i) : Base( Tuple(d+1) )
/*{\Mcreate returns a variable |\Mvar| of type |\Mname| initialized
to the direction of the $i$-th base vector of dimension $d$.
\precond $0 \leq i < d$.}*/
{ entry(d) = 1;
if ( d==0 ) return;
CGAL_assertion_msg((0<=i&&i<d), "DirectionHd::base: index out of range.");
entry(i) = 1;
}
DirectionHd(const RT& x, const RT& y) : Base( Tuple(x,y,1) ) {}
/*{\Mcreate introduces a variable |\Mvar| of type |\Mname| in
$2$-dimensional space. }*/
DirectionHd(int a, int b) :
Base( Tuple(RT(a),RT(b),RT(1),MatchHelper()) ) {}
DirectionHd(const RT& x, const RT& y, const RT& z) :
Base( Tuple(x,y,z,1) ) {}
/*{\Mcreate introduces a variable |\Mvar| of type |\Mname| in
$3$-dimensional space. }*/
DirectionHd(int a, int b, int c) :
Base( Tuple(RT(a),RT(b),RT(c),RT(1)) ) {}
DirectionHd(const DirectionHd<RT,LA>& p) : Base(p) {}
~DirectionHd() {}
/*{\Moperations 5 3}*/
int dimension() const { return ptr()->size()-1; }
/*{\Mop returns the dimension of |\Mvar|. }*/
RT delta(int i) const
/*{\Mop returns the $i$-th component of |\Mvar|.
\precond $0 \leq i < d$.}*/
{ CGAL_assertion_msg((0<=i && i<(dimension())), "DirectionHd::delta():\
index out of range.");
return entry(i);
}
RT D() { return entry(dimension()); }
RT operator[](int i) const
/*{\Marrop returns the $i$-th delta of |\Mvar|.
\precond $0 \leq i < d$.}*/
{ return delta(i); }
Delta_const_iterator deltas_begin() const { return ptr()->begin(); }
/*{\Mop returns an iterator pointing to the first delta of |\Mvar|. }*/
Delta_const_iterator deltas_end() const { return ptr()->last(); }
/*{\Mop returns an iterator pointing beyond the last delta of |\Mvar|. }*/
VectorHd<RT,LA> vector() const;
/*{\Mop returns a vector pointing in direction |\Mvar|. }*/
bool is_degenerate() const
/*{\Mop returns true iff |\Mvar.vector()| is the zero vector.}*/
{ for (int i=0; i<dimension(); ++i)
if ( delta(i) != RT(0) ) return false;
return true; }
DirectionHd<RT,LA> transform(const Aff_transformationHd<RT,LA>& t) const;
/*{\Mop returns $t(p)$. }*/
DirectionHd<RT,LA> opposite() const
/*{\Mop returns the direction opposite to |\Mvar|. }*/
{ DirectionHd<RT,LA> result(*this); // creates a copied object!
result.copy_on_write(); // creates a copied object!
result.ptr()->invert(dimension());
return result;
}
DirectionHd<RT,LA> operator- () const
/*{\Munop returns the direction opposite to |\Mvar|.}*/
{ return opposite(); }
static Comparison_result cmp(
const DirectionHd<RT,LA>& h1, const DirectionHd<RT,LA>& h2);
bool operator==(const DirectionHd<RT,LA>& w) const
{ if ( this->identical(w) ) return true;
if ( dimension()!=w.dimension() ) return false;
return (DirectionHd<RT,LA>::cmp(*this,w) == EQUAL);
}
bool operator!=(const DirectionHd<RT,LA>& w) const
{ return !operator==(w); }
/*{\Mtext \headerline{Downward compatibility}
We provide all operations of the lower dimensional interface |dx()|,
|dy()|, |dz()|.}*/
RT dx() const { return delta(0); }
RT dy() const { return delta(1); }
RT dz() const { return delta(2); }
friend std::istream& operator>> <>
(std::istream& I, DirectionHd<RT,LA>& d);
friend std::ostream& operator<< <>
(std::ostream& O, const DirectionHd<RT,LA>& d);
}; // end of class DirectionHd
/*{\Mimplementation
Directions are implemented by arrays of integers as an item type. All
operations like creation, initialization, tests, inversion, input and
output on a direction $d$ take time $O(|d.dimension()|)$. |dimension()|,
coordinate access and conversion take constant time. The space
requirement is $O(|d.dimension()|)$. }*/
} //namespace CGAL
#endif // CGAL_DIRECTIONHD_H
//----------------------- end of file ----------------------------------
|