Loading...
Searching...
No Matches
circle3.h
Go to the documentation of this file.
// -*- 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
{
template <typename T>
class TCircle3;
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);
template <typename T>
class TCircle3
{
public:
BALL_CREATE(TCircle3<T>)
TCircle3()
: p(),
n(),
radius(0)
{
}
TCircle3(const TCircle3& circle)
: p(circle.p),
n(circle.n),
radius(circle.radius)
{
}
TCircle3(const TVector3<T>& point, const TVector3<T>& normal, const T& radius)
: p(point),
n(normal),
radius(radius)
{
}
virtual ~TCircle3()
{
}
virtual void clear()
{
p.clear();
n.clear();
radius = (T)0;
}
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;
}
void set(const TCircle3& circle)
{
p = circle.p;
n = circle.n;
radius = circle.radius;
}
void set(const TVector3<T>& point, const TVector3<T>& normal, const T& rad)
{
p = point;
n = normal;
radius = rad;
}
TCircle3& operator = (const TCircle3& circle)
{
p = circle.p;
n = circle.n;
radius = circle.radius;
return *this;
}
void get(TCircle3& circle) const
{
circle.p = p;
circle.n = n;
circle.radius = radius;
}
void get(TVector3<T>& point, TVector3<T>& normal, T& rhs) const
{
point = p;
normal = n;
rhs = radius;
}
bool operator == (const TCircle3& circle) const
{
return (p == circle.p && n == circle.n && Maths::isEqual(radius, circle.radius));
}
bool operator != (const TCircle3& circle) const
{
return (p != circle.p || n != circle.n || Maths::isNotEqual(radius, circle.radius));
}
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));
}
}
bool isValid() const
{
return true;
}
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);
}
TVector3<T> p;
TVector3<T> n;
T radius;
};
#ifdef BALL_COMPILER_MSVC
template class BALL_EXPORT TCircle3<float>;
#endif
typedef TCircle3<float> Circle3;
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;
}
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
exception.h
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::TCircle3
Definition circle3.h:46
BALL::TCircle3::TCircle3
TCircle3(const TCircle3 &circle)
Definition circle3.h:70
BALL::TCircle3::isValid
bool isValid() const
Definition circle3.h:240
BALL::TCircle3::operator!=
bool operator!=(const TCircle3 &circle) const
Definition circle3.h:206
BALL::TCircle3::TCircle3
TCircle3(const TVector3< T > &point, const TVector3< T > &normal, const T &radius)
Definition circle3.h:83
BALL::TCircle3::has
bool has(const TVector3< T > &point, bool on_surface=false) const
Definition circle3.h:217
BALL::TCircle3::TCircle3
TCircle3()
Definition circle3.h:59
BALL::TCircle3< float >::p
TVector3< float > p
Definition circle3.h:277
BALL::TCircle3::~TCircle3
virtual ~TCircle3()
Definition circle3.h:94
BALL::TCircle3::set
void set(const TVector3< T > &point, const TVector3< T > &normal, const T &rad)
Definition circle3.h:146
BALL::TCircle3::get
void get(TCircle3 &circle) const
Definition circle3.h:170
BALL::TCircle3::swap
void swap(TCircle3 &circle)
Definition circle3.h:116
BALL::TCircle3::get
void get(TVector3< T > &point, TVector3< T > &normal, T &rhs) const
Definition circle3.h:182
BALL::TCircle3::dump
void dump(std::ostream &s=std::cout, Size depth=0) const
Definition circle3.h:251
BALL::TCircle3< float >::radius
float radius
Definition circle3.h:287
BALL::TCircle3< float >::n
TVector3< float > n
Definition circle3.h:282
BALL::TCircle3::clear
virtual void clear()
Definition circle3.h:101
BALL::TCircle3::operator=
TCircle3 & operator=(const TCircle3 &circle)
Definition circle3.h:157
BALL::TCircle3::operator==
bool operator==(const TCircle3 &circle) const
Definition circle3.h:198
BALL::TCircle3::set
void set(const TCircle3 &circle)
Definition circle3.h:134
BALL::TVector3
Definition vector3.h:71
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL::Circle3
TCircle3< float > Circle3
Definition circle3.h:301
BALL::operator<<
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
BALL_DUMP_STREAM_PREFIX
#define BALL_DUMP_STREAM_PREFIX(os)
Definition macros.h:391
BALL_DUMP_STREAM_SUFFIX
#define BALL_DUMP_STREAM_SUFFIX(os)
Definition macros.h:395
BALL_DUMP_DEPTH
#define BALL_DUMP_DEPTH(os, depth)
Definition macros.h:390
BALL_DUMP_HEADER
#define BALL_DUMP_HEADER(os, cl, ob)
Definition macros.h:393
BALL::Maths::isNotEqual
bool isNotEqual(const T1 &a, const T2 &b)
Definition MATHS/common.h:224
BALL::Maths::isZero
bool isZero(const T &t)
Definition MATHS/common.h:189
BALL::Maths::isLessOrEqual
bool isLessOrEqual(const T1 &a, const T2 &b)
Definition MATHS/common.h:249
BALL::Maths::isEqual
bool isEqual(const T1 &a, const T2 &b)
Definition MATHS/common.h:212
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::operator>>
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
Definition regularData1D.h:802
vector3.h