_Tuple4.cc

Go to the documentation of this file.
00001 #include <vecmath/_Tuple4.h>
00002 //#include <java/lang/String.h>
00003 //
00004 
00005 template <class Type>
00006 void _Tuple4<Type>::clamp(Type min, Type max, const _Tuple4<Type>& t)
00007 {
00008     DEBUGTUPLE4(cout << "_Tuple4 clamp( " << min << ", " << max
00009                 << ", " << t << " )");
00010     if (t.x < min)
00011         x = min;
00012     else if (t.x > max)
00013         x = max;
00014     else
00015         x = t.x;
00016 
00017     if (t.y < min)
00018         y = min;
00019     else if (t.y > max)
00020         y = max;
00021     else
00022         y = t.y;
00023 
00024     if (t.z < min)
00025         z = min;
00026     else if (t.z > max)
00027         z = max;
00028     else
00029         z = t.z;
00030 
00031     if (t.w < min)
00032         w = min;
00033     else if (t.w > max)
00034         w = max;
00035     else
00036         w = t.w;
00037 
00038     DEBUGTUPLE4(cout << " = " << *this << endl);
00039 }
00040 
00041 template <class Type>
00042 void _Tuple4<Type>::clampMax(Type max, const _Tuple4<Type>& t)
00043 {
00044     DEBUGTUPLE4(cout << "_Tuple4 clampMax( " << max << ", " << t << " ) ");
00045     x = (t.x > max) ? max : t.x;
00046     y = (t.y > max) ? max : t.y;
00047     z = (t.z > max) ? max : t.z;
00048     w = (t.w > max) ? max : t.w;
00049     DEBUGTUPLE4(cout << " = " << *this << endl);
00050 }
00051 
00052 template <class Type>
00053 void _Tuple4<Type>::clampMin(Type min, const _Tuple4<Type>& t)
00054 {
00055     DEBUGTUPLE4(cout << "_Tuple4 clampMin( " << min << ", " << t << " ) ");
00056     x = (t.x < min) ? min : t.x;
00057     y = (t.y < min) ? min : t.y;
00058     z = (t.z < min) ? min : t.z;
00059     w = (t.w < min) ? min : t.w;
00060     DEBUGTUPLE4(cout << " = " << *this << endl);
00061 }
00062 
00063 template <class Type>
00064 void _Tuple4<Type>::interpolate(_Tuple4<Type> &t1, const _Tuple4<Type> &t2, double alpha)
00065 {
00066     set((Type) ((1.0 - alpha) * t1.x + alpha * t2.x),
00067         (Type) ((1.0 - alpha) * t1.y + alpha * t2.y),
00068         (Type) ((1.0 - alpha) * t1.z + alpha * t2.z),
00069         (Type) ((1.0 - alpha) * t1.w + alpha * t2.w));
00070 }
00071 
00072 #if 0   
00073 String &_Tuple4<byte>::toString(String &s)
00074 {
00075     char a[200];
00076     sprintf(a, "x:%d y:%d z:%d w:%d", x, y, z, w);
00077     s = a;
00078 
00079     return s;
00080 }
00081 
00082 String &_Tuple4<double>::toString(String &s)
00083 {
00084     char a[200];
00085     sprintf(a, "x:%f y:%f z:%f w:%f", x, y, z, w);
00086     s = a;
00087 
00088     return s;
00089 }
00090 
00091 String &_Tuple4<float>::toString(String &s)
00092 {
00093     char a[200];
00094     sprintf(a, "x:%f y:%f z:%f w:%f", x, y, z, w);
00095     s = a;
00096 
00097     return s;
00098 }
00099 
00100 String &_Tuple4<int>::toString(String &s)
00101 {
00102     char a[200];
00103     sprintf(a, "x:%d y:%d z:%d w:%d", x, y, z, w);
00104     s = a;
00105 
00106     return s;
00107 }
00108 #endif
00109 template <class Type> std::ostream& operator <<(std::ostream& os, const _Tuple4<Type>& t)
00110 {
00111     return os << "(" << t.x << ", " << t.y << ", " << t.z << ", " << t.w << ")";
00112 }
00113 
00114 template <class Type> std::ostream& operator <<(std::ostream& os, const _Tuple4<Type>* t)
00115 {
00116     return os << *t;
00117 }
00118 
00119 template class _Tuple4<byte>;
00120 template class _Tuple4<double>;
00121 template class _Tuple4<float>;
00122 template class _Tuple4<int>;
00123 
00124 template std::ostream& operator <<(std::ostream&, const _Tuple4<double>&);
00125 template std::ostream& operator <<(std::ostream&, const _Tuple4<double>*);
00126 template std::ostream& operator <<(std::ostream&, const _Tuple4<float>&);
00127 template std::ostream& operator <<(std::ostream&, const _Tuple4<float>*);
00128 template std::ostream& operator <<(std::ostream&, const _Tuple4<int>&);
00129 template std::ostream& operator <<(std::ostream&, const _Tuple4<int>*);
00130 

Generated on Thu Sep 29 13:39:45 2005 for vecmath by  doxygen 1.4.4