Basic working for the ogl fixpoint abstraction
This commit is contained in:
parent
da291e0f22
commit
914df932d9
@ -166,18 +166,67 @@ namespace etk{
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (coord2D_ts t) {
|
||||
|
||||
CCout& operator << (Coord2D<float> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (coord3D_ts t) {
|
||||
CCout& operator << (Coord2D<int32_t> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i)", t.x, t.y);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (Coord2D<oglt> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", (float)t.x, (float)t.y);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (Coord3D<float> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (Coord3D<int32_t> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i,%i)", t.x, t.y, t.z);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (Coord3D<oglt> t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", (float)t.x, (float)t.y, (float)t.z);
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (coord2D_ts t) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", UNFIXED(t.x), UNFIXED(t.y));
|
||||
#elif defined(EWOL_PECISION_DOUBLE)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%lf,%lf)", t.x, t.y);
|
||||
#else
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y);
|
||||
#endif
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (coord3D_ts t) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", UNFIXED(t.x), UNFIXED(t.y), UNFIXED(t.z));
|
||||
#elif defined(EWOL_PECISION_DOUBLE)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%lf,%lf,%lf)", t.x, t.y, t.z);
|
||||
#else
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z);
|
||||
#endif
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (texCoord_ts t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", t.u, t.v);
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", UNFIXED(t.u), UNFIXED(t.v));
|
||||
#elif defined(EWOL_PECISION_DOUBLE)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%lf,%lf}", t.u, t.v);
|
||||
#else
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", t.u, t.v);
|
||||
#endif
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
@ -187,7 +236,13 @@ namespace etk{
|
||||
return *this;
|
||||
}
|
||||
CCout& operator << (clipping_ts t) {
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h);
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", UNFIXED(t.x), UNFIXED(t.y), UNFIXED(t.w), UNFIXED(t.h));
|
||||
#elif defined(EWOL_PECISION_DOUBLE)
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%lf,%lf) size=(%lf,%lf)", t.x, t.y, t.w, t.h);
|
||||
#else
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h);
|
||||
#endif
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
return *this;
|
||||
}
|
||||
|
@ -68,27 +68,36 @@ typedef enum {
|
||||
#define etk_max(elemA, elemB) ((elemA)<(elemB)) ? (elemB) : (elemA)
|
||||
#define etk_avg(minimim, elem, maximum) ((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem)
|
||||
|
||||
|
||||
//#define EWOL_PECISION_FIXPOINT
|
||||
|
||||
#include <etk/TypesCoordonate.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#ifdef EWOL_PECISION_DOUBLE
|
||||
typedef double etkFloat_t;
|
||||
#define oglTypeFloat_t GL_DOUBLE
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
// TODO : Remove deprecated elements :
|
||||
typedef int32_t etkFloat_t;
|
||||
#define oglTypeFloat_t GL_FIXED
|
||||
#else
|
||||
typedef float etkFloat_t;
|
||||
// TODO : Remove deprecated elements :
|
||||
typedef float etkFloat_t;
|
||||
#define oglTypeFloat_t GL_FLOAT
|
||||
#endif
|
||||
|
||||
// TODO : Remove deprecated elements :
|
||||
typedef struct {
|
||||
etkFloat_t x;
|
||||
etkFloat_t y;
|
||||
etkFloat_t z;
|
||||
}coord3D_ts;
|
||||
|
||||
// TODO : Remove deprecated elements :
|
||||
typedef struct {
|
||||
etkFloat_t x;
|
||||
etkFloat_t y;
|
||||
}coord2D_ts;
|
||||
|
||||
// TODO : Remove deprecated elements :
|
||||
typedef struct {
|
||||
etkFloat_t u;
|
||||
etkFloat_t v;
|
||||
|
851
Sources/libetk/etk/TypesCoordonate.h
Normal file
851
Sources/libetk/etk/TypesCoordonate.h
Normal file
@ -0,0 +1,851 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file etk/TypesCoordonate.h
|
||||
* @brief Ewol Tool Kit : generique coordonate type abstraction for openGl
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/06/2012
|
||||
* @par Project
|
||||
* Ewol TK
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ETK_TYPES_COORDONATES_H__
|
||||
#define __ETK_TYPES_COORDONATES_H__
|
||||
|
||||
class oglt
|
||||
{
|
||||
public:
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
int32_t val;
|
||||
#elseif defined(EWOL_PECISION_DOUBLE)
|
||||
double val;
|
||||
#else
|
||||
float val;
|
||||
#endif
|
||||
public:
|
||||
/*****************************************************
|
||||
* Constructor
|
||||
*****************************************************/
|
||||
oglt(void) : val(0) { };
|
||||
oglt(const oglt& obj) : val(obj.val) { };
|
||||
~oglt(void) { };
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
oglt(const int32_t val) : val(val << 16) { };
|
||||
oglt(const float val) : val(val*65536.0) { };
|
||||
oglt(const double val) : val(val*65536.0) { };
|
||||
operator int32_t() const { return val>>16; }
|
||||
operator float() const { return (float)((float)val/(float)65536.0); }
|
||||
operator double() const { return (double)((double)val/(double)65536.0); }
|
||||
#else
|
||||
oglt(const int32_t val) : val(val) { };
|
||||
oglt(const float val) : val(val) { };
|
||||
oglt(const double val) : val(val) { };
|
||||
operator int32_t() const { return (int32_t)val; }
|
||||
operator float() const { return (float)val; }
|
||||
operator double() const { return (double)val; }
|
||||
#endif
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const oglt& operator= (const oglt& obj ) {
|
||||
val = obj.val;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
const bool operator== (const oglt& obj) const {
|
||||
return (obj.val == val) ? true : false;
|
||||
}
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const oglt& obj) const {
|
||||
return (obj.val == val) ? false : true;
|
||||
}
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const oglt& operator+= (const oglt& obj) {
|
||||
val += obj.val;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
const oglt& operator+ (const oglt& obj) {
|
||||
val += obj.val;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const oglt& operator-= (const oglt& obj) {
|
||||
val -= obj.val;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
const oglt& operator- (const oglt& obj) {
|
||||
val -= obj.val;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const oglt& operator/= (const oglt& obj) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
val = ((int64_t)val<<16) / obj.val;
|
||||
#else
|
||||
val /= obj.val;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
const oglt& operator/ (const oglt& obj) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
val = ((int64_t)val<<16) / obj.val;
|
||||
#else
|
||||
val /= obj.val;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const oglt& operator*= (const oglt& obj) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
int64_t tmpVal = (int64_t)val * (int64_t)obj.val;
|
||||
val = tmpVal >> 16;
|
||||
#else
|
||||
val *= obj.val;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
const oglt& operator* (const oglt& obj) {
|
||||
#if defined(EWOL_PECISION_FIXPOINT)
|
||||
int64_t tmpVal = (int64_t)val * (int64_t)obj.val;
|
||||
val = tmpVal >> 16;
|
||||
#else
|
||||
val *= obj.val;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
oglt& operator++() // prefix
|
||||
{
|
||||
++val;
|
||||
return *this;
|
||||
}
|
||||
oglt operator++(int unused) // postfix
|
||||
{
|
||||
oglt result = *this;
|
||||
++(*this);
|
||||
return result;
|
||||
}
|
||||
/*****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
oglt& operator--() // prefix
|
||||
{
|
||||
--val;
|
||||
return *this;
|
||||
}
|
||||
oglt operator--(int unused) // postfix
|
||||
{
|
||||
oglt result = *this;
|
||||
--(*this);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T> class Coord2D
|
||||
{
|
||||
public:
|
||||
T x;
|
||||
T y;
|
||||
public:
|
||||
/*****************************************************
|
||||
* Constructor
|
||||
*****************************************************/
|
||||
Coord2D(void) : x(0), y(0) { };
|
||||
Coord2D(double _x, double _y) : x(_x), y(_y) { };
|
||||
Coord2D(float _x, float _y) : x(_x), y(_y) { };
|
||||
Coord2D(int32_t _x, int32_t _y) : x(_x), y(_y) { };
|
||||
Coord2D(const Coord2D<double>& obj) : x((T)obj.x), y((T)obj.y) { };
|
||||
Coord2D(const Coord2D<float>& obj) : x((T)obj.x), y((T)obj.y) { };
|
||||
Coord2D(const Coord2D<int32_t>& obj) : x((T)obj.x), y((T)obj.y) { };
|
||||
Coord2D(const Coord2D<oglt>& obj) : x((T)obj.x), y((T)obj.y) { };
|
||||
~Coord2D(void) { };
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const Coord2D<T>& operator= (const Coord2D<double>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator= (const Coord2D<float>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator= (const Coord2D<int32_t>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator= (const Coord2D<oglt>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const Coord2D<double>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord2D<float>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord2D<int32_t>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord2D<oglt>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const Coord2D<double>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord2D<float>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord2D<int32_t>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord2D<oglt>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const Coord2D<T>& operator+= (const Coord2D<double>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator+= (const Coord2D<float>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator+= (const Coord2D<int32_t>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator+= (const Coord2D<oglt>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
Coord2D<T> operator+ (const Coord2D<double>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator+ (const Coord2D<float>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator+ (const Coord2D<int32_t>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator+ (const Coord2D<oglt>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const Coord2D<T>& operator-= (const Coord2D<double>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator-= (const Coord2D<float>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator-= (const Coord2D<int32_t>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator-= (const Coord2D<oglt>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
Coord2D<T> operator- (const Coord2D<double>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator- (const Coord2D<float>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator- (const Coord2D<int32_t>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator- (const Coord2D<oglt>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const Coord2D<T>& operator/= (const Coord2D<double>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator/= (const Coord2D<float>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator/= (const Coord2D<int32_t>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator/= (const Coord2D<oglt>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
Coord2D<T> operator/ (const Coord2D<double>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator/ (const Coord2D<float>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator/ (const Coord2D<int32_t>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator/ (const Coord2D<oglt>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const Coord2D<T>& operator*= (const Coord2D<double>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator*= (const Coord2D<float>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator*= (const Coord2D<int32_t>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
const Coord2D<T>& operator*= (const Coord2D<oglt>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
Coord2D<T> operator* (const Coord2D<double>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator* (const Coord2D<float>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator* (const Coord2D<int32_t>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator* (const Coord2D<oglt>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
Coord2D<T>& operator++() // prefix
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
return *this;
|
||||
}
|
||||
Coord2D<T> operator++(int unused) // postfix
|
||||
{
|
||||
Coord2D<T> result = *this;
|
||||
++(*this);
|
||||
return result;
|
||||
}
|
||||
/*****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
Coord2D<T>& operator--() // prefix
|
||||
{
|
||||
--x;
|
||||
--y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Coord2D<T> operator--(int unused) // postfix
|
||||
{
|
||||
Coord2D<T> result = *this;
|
||||
--(*this);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////:
|
||||
|
||||
template <typename T> class Coord3D
|
||||
{
|
||||
public:
|
||||
T x;
|
||||
T y;
|
||||
T z;
|
||||
public:
|
||||
/*****************************************************
|
||||
* Constructor
|
||||
*****************************************************/
|
||||
Coord3D(void) : x(0), y(0), z(0) { };
|
||||
Coord3D(double _x, double _y, double _z) : x(_x), y(_y), z(_z) { };
|
||||
Coord3D(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { };
|
||||
Coord3D(int32_t _x, int32_t _y, int32_t _z) : x(_x), y(_y), z(_z) { };
|
||||
Coord3D(const Coord3D<double>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
|
||||
Coord3D(const Coord3D<float>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
|
||||
Coord3D(const Coord3D<int32_t>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
|
||||
Coord3D(const Coord3D<oglt>& obj) : x((T)obj.x), y((T)obj.y), z((T)obj.z) { };
|
||||
~Coord3D(void) { };
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const Coord3D<T>& operator= (const Coord3D<double>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
z = (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator= (const Coord3D<float>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
z = (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator= (const Coord3D<int32_t>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
z = (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator= (const Coord3D<oglt>& obj ) {
|
||||
x = (T)obj.x;
|
||||
y = (T)obj.y;
|
||||
z = (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const Coord3D<double>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord3D<float>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord3D<int32_t>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator== (const Coord3D<oglt>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const Coord3D<double>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord3D<float>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord3D<int32_t>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!= (const Coord3D<oglt>& obj) const {
|
||||
if ((T)obj.x == x && (T)obj.y == y && (T)obj.z == z) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const Coord3D<T>& operator+= (const Coord3D<double>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator+= (const Coord3D<float>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator+= (const Coord3D<int32_t>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator+= (const Coord3D<oglt>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
Coord3D<T> operator+ (const Coord3D<double>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator+ (const Coord3D<float>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator+ (const Coord3D<int32_t>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator+ (const Coord3D<oglt>& obj) {
|
||||
x += (T)obj.x;
|
||||
y += (T)obj.y;
|
||||
z += (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const Coord3D<T>& operator-= (const Coord3D<double>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator-= (const Coord3D<float>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator-= (const Coord3D<int32_t>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator-= (const Coord3D<oglt>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
Coord3D<T> operator- (const Coord3D<double>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator- (const Coord3D<float>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator- (const Coord3D<int32_t>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator- (const Coord3D<oglt>& obj) {
|
||||
x -= (T)obj.x;
|
||||
y -= (T)obj.y;
|
||||
z -= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const Coord3D<T>& operator/= (const Coord3D<double>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator/= (const Coord3D<float>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator/= (const Coord3D<int32_t>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator/= (const Coord3D<oglt>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
Coord3D<T> operator/ (const Coord3D<double>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator/ (const Coord3D<float>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator/ (const Coord3D<int32_t>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator/ (const Coord3D<oglt>& obj) {
|
||||
x /= (T)obj.x;
|
||||
y /= (T)obj.y;
|
||||
z /= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const Coord3D<T>& operator*= (const Coord3D<double>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator*= (const Coord3D<float>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator*= (const Coord3D<int32_t>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
const Coord3D<T>& operator*= (const Coord3D<oglt>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
Coord3D<T> operator* (const Coord3D<double>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator* (const Coord3D<float>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator* (const Coord3D<int32_t>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator* (const Coord3D<oglt>& obj) {
|
||||
x *= (T)obj.x;
|
||||
y *= (T)obj.y;
|
||||
z *= (T)obj.z;
|
||||
return *this;
|
||||
}
|
||||
/*****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
Coord3D<T>& operator++() // prefix
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
++z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator++(int unused) // postfix
|
||||
{
|
||||
Coord3D<T> result = *this;
|
||||
++(*this);
|
||||
return result;
|
||||
}
|
||||
/*****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
Coord3D<T>& operator--() // prefix
|
||||
{
|
||||
--x;
|
||||
--y;
|
||||
--z;
|
||||
return *this;
|
||||
}
|
||||
Coord3D<T> operator--(int unused) // postfix
|
||||
{
|
||||
Coord3D<T> result = *this;
|
||||
--(*this);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user