|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCG_POINT_H
|
|
Toshihiro Shimizu |
890ddd |
#define TCG_POINT_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// tcg Generic Point Class
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
The Point class models a point in a bidimensional vector space. It has 2 members,
|
|
Toshihiro Shimizu |
890ddd |
x and y, representing its coordinates, and a constructor prototype:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Point_class(const value_type& x, const value_type& y);
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct PointT {
|
|
Toshihiro Shimizu |
890ddd |
typedef T value_type;
|
|
Toshihiro Shimizu |
890ddd |
value_type x, y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PointT() : x(0), y(0) {}
|
|
Toshihiro Shimizu |
890ddd |
PointT(const value_type &x_, const value_type &y_) : x(x_), y(y_) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const PointT &other) const { return (x == other.x) && (y == other.y); }
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const PointT &other) const { return !operator==(other); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Common typedefs
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef PointT<int> Point;</int>
|
|
Toshihiro Shimizu |
890ddd |
typedef PointT<int> PointI;</int>
|
|
Toshihiro Shimizu |
890ddd |
typedef PointT<double> PointD;</double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// tcg Generic Point Traits
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename p=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct point_traits {
|
|
Toshihiro Shimizu |
890ddd |
typedef P point_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef typename P::value_type value_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef typename P::value_type float_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type x(const point_type &p) { return p.x; }
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type y(const point_type &p) { return p.y; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct point_traits<pointi> {</pointi>
|
|
Toshihiro Shimizu |
890ddd |
typedef PointI point_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef PointI::value_type value_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef double float_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type x(const point_type &p) { return p.x; }
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type y(const point_type &p) { return p.y; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //TCG_POINT_H
|