/usr/include/BALL/MATHS/circle3.h is in libball1.4-dev 1.4.1+20111206-3.
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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: circle3.h,v 1.42 2004/07/05 20:57:28 oliver Exp $
//
#ifndef BALL_MATHS_CIRCLE3_H
#define BALL_MATHS_CIRCLE3_H
#ifndef BALL_COMMON_EXCEPTION_H
# include <BALL/COMMON/exception.h>
#endif
#ifndef BALL_MATHS_VECTOR3_H
# include <BALL/MATHS/vector3.h>
#endif
namespace BALL
{
/** \defgroup Circle Generic three-dimensional circle.
\ingroup GeometricObjects
*/
//@{
template <typename T>
class TCircle3;
/** @name Storers
\ingroup Circle
*/
//@{
///
template <typename T>
std::istream& operator >> (std::istream& s, TCircle3<T>& circle);
///
template <typename T>
std::ostream& operator << (std::ostream& s, const TCircle3<T>& circle);
//@}
/** Generic Circle in Three-Dimensional Space.
*/
template <typename T>
class TCircle3
{
public:
BALL_CREATE(TCircle3<T>)
/** @name Constructors and Destructors
*/
//@{
/** Default constructor.
This method creates a new TCircle3 object. The three components
are initialized to <tt>0</tt>.
*/
TCircle3()
: p(),
n(),
radius(0)
{
}
/** Copy constructor.
Create a new TCircle3 object from another.
@param circle the TCircle3 object to be copied
*/
TCircle3(const TCircle3& circle)
: p(circle.p),
n(circle.n),
radius(circle.radius)
{
}
/** Detailed constructor.
Create a new TCircle3 object from the central point, the normal and a radius.
@param point assigned to the point
@param normal assigned to the normal
@param radius assigned tp the radius
*/
TCircle3(const TVector3<T>& point, const TVector3<T>& normal, const T& radius)
: p(point),
n(normal),
radius(radius)
{
}
/** Destructor.
Destructs the TCircle3 object. As there are no dynamic
data structures, nothing happens.
*/
virtual ~TCircle3()
{
}
/** Clear method.
The values are set to 0.
*/
virtual void clear()
{
p.clear();
n.clear();
radius = (T)0;
}
//@}
/** @name Assignment
*/
//@{
/** Swap the contents of two circles.
@param circle the circle to swap contents with
*/
void swap(TCircle3& circle)
{
TVector3<T> temp_vector(p);
p = circle.p;
circle.p = temp_vector;
temp_vector = n;
n = circle.n;
circle.n = temp_vector;
T temp = radius;
radius = circle.radius;
circle.radius = temp;
}
/** Assign from another TCircle3.
@param circle the TCirce3 object to assign from
*/
void set(const TCircle3& circle)
{
p = circle.p;
n = circle.n;
radius = circle.radius;
}
/** Assign the circle components.
@param point assigned to the point
@param normal assigned to the normal
@param rad assigned to the radius
*/
void set(const TVector3<T>& point, const TVector3<T>& normal, const T& rad)
{
p = point;
n = normal;
radius = rad;
}
/** Assignment operator.
Assign the components from another circle.
@param circle the circle to assign from
**/
TCircle3& operator = (const TCircle3& circle)
{
p = circle.p;
n = circle.n;
radius = circle.radius;
return *this;
}
/** Assign to another TCircle3.
Assigns the components to another circle.
@param circle the circle to be assigned to
*/
void get(TCircle3& circle) const
{
circle.p = p;
circle.n = n;
circle.radius = radius;
}
/** Assign to two variables of type TVector3 and one <tt>T</tt> value.
@param point the center point
@param normal the circle normal
@param rhs the radius
*/
void get(TVector3<T>& point, TVector3<T>& normal, T& rhs) const
{
point = p;
normal = n;
rhs = radius;
}
//@}
/** @name Predicates
*/
//@{
/** Equality operator.
@return bool, <b>true</b> if all components are equal, <b>false</b> otherwise
*/
bool operator == (const TCircle3& circle) const
{
return (p == circle.p && n == circle.n && Maths::isEqual(radius, circle.radius));
}
/** Inequality operator.
@return bool, <b>false</b> if all components are equal, <b>true</b> otherwise
*/
bool operator != (const TCircle3& circle) const
{
return (p != circle.p || n != circle.n || Maths::isNotEqual(radius, circle.radius));
}
/** Test if a given point is a member of the circle.
Optional it can be testet, if the point lies on the surface.
@param point the point to be tested
@param on_surface true to test the surface (default = false)
@return bool, <b>true</b> or <b>false</b>
*/
bool has(const TVector3<T>& point, bool on_surface = false) const
{
if (on_surface)
{
return (Maths::isZero(n * (point - p))
&& Maths::isEqual(p.getDistance(point), radius));
}
else
{
return (Maths::isZero(n * (point - p))
&& Maths::isLessOrEqual(p.getDistance(point), radius));
}
}
//@}
/** @name Debugging and Diagnostics
*/
//@{
/** Test if instance is valid.
Always returns true
@return bool <b>true</b>
*/
bool isValid() const
{
return true;
}
/** Internal state dump.
Dump the current internal state of {\em *this} to
the output ostream <b> s </b> with dumping depth <b> depth </b>.
@param s - output stream where to output the internal state of {\em *this}
@param depth - the dumping depth
*/
void dump(std::ostream& s = std::cout, Size depth = 0) const
{
BALL_DUMP_STREAM_PREFIX(s);
BALL_DUMP_HEADER(s, this, this);
BALL_DUMP_DEPTH(s, depth);
s << " position: " << p << std::endl;
BALL_DUMP_DEPTH(s, depth);
s << " normal: " << n << std::endl;
BALL_DUMP_DEPTH(s, depth);
s << " radius: " << radius << std::endl;
BALL_DUMP_STREAM_SUFFIX(s);
}
//@}
/** @name Attributes
*/
//@{
/** Circle Center.
This point describes the center of the circle.
*/
TVector3<T> p;
/** Normal vector.
This vector is orthogonal to the circle's plane.
*/
TVector3<T> n;
/** Radius.
The radius of the circle.
*/
T radius;
//@}
};
//@}
/** needed for windows dlls **/
#ifdef BALL_COMPILER_MSVC
template class BALL_EXPORT TCircle3<float>;
#endif
/** Default three-dimensional circle class of type <b>float</b>
\ingroup Circle
*/
typedef TCircle3<float> Circle3;
/** Input operator.
Reads in two TVector3 and a <b>T</b> value: p, n, radius
*/
template <typename T>
std::istream& operator >> (std::istream& s, TCircle3<T>& circle)
{
char c;
s >> c;
s >> circle.p >> circle.n >> circle.radius;
s >> c;
return s;
}
/** Output Operator.
Writes the values of <tt>p</tt>, <tt>n</tt>, and <tt>radius</tt> to an
output stream. The three values are separated by spaces and enclosed in brackets. \par
<b>Example:</b> \par
<tt>((0 0 0) (1 2 1) 3.5)</tt>
@see TVector3::operator<<
*/
template <typename T>
std::ostream& operator << (std::ostream& s, const TCircle3<T>& circle)
{
return s << '(' << circle.p
<< ' ' << circle.n
<< ' ' << circle.radius
<< ')';
}
} // namespace BALL
#endif // BALL_MATHS_CIRCLE3_H
|