00001 /******************************************************************************
00002
00003 Copyright 2008 Departamento de Realidad Virtual
00004 y Unidad de Cómputo Aplicado DGSGA, UNAM.
00005
00006
00007 This file is part of RBF++.
00008
00009 RBF++ is free software: you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation, either version 3 of the License, or
00012 (at your option) any later version.
00013
00014 RBF++ is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 GNU General Public License for more details.
00018
00019 You should have received a copy of the GNU General Public License
00020 along with RBF++. If not, see <http://www.gnu.org/licenses/>.
00021
00022
00023 *******************************************************************************/
00024
00025
00026
00027 #ifndef POINT2DT_H_
00028 # define POINT2DT_H_
00029
00030
00031 #include <LA/Point.h>
00032 namespace LA{
00033
00051 template<typename T>
00052 class Point2dT : public Point<T>{
00053
00054 public:
00055 Point2dT():Point<T>(2){};
00056 Point2dT(T x,T y):Point<T>(2)
00057 {
00058 Point<T>::_v[0] = x;
00059 Point<T>::_v[1] = y;
00060 }
00061 //explicit conversion
00062 template<typename U>
00063 Point<U> & operator=(const Point<U> & p){
00064
00065 Point<U>::_v[0] = p[0];
00066 Point<U>::_v[1] = p[1];
00067
00068 return *this;
00069 }
00070
00071 template<typename U>
00072 friend U operator^(const Point2dT<U> &, const Point2dT<U> &);
00073
00074 T& X(){return Point<T>::_v[0];}
00075 T& Y(){return Point<T>::_v[1];}
00076 void lineto (Point2dT<T>*);
00077
00078 };
00079
00080
00081 template<typename U>
00082 U operator^(const Point2dT<U> & pt1, const Point2dT<U> & pt2){
00083 return pt1[0]*pt2[1] - pt1[1]*pt2[0];
00084 }
00085
00086 template<typename T>
00087 void Point2dT<T>::lineto(Point2dT<T> * p){
00088
00089 cout << Point<T>::_v[0] <<" "
00090 << Point<T>::_v[1] <<" moveto "
00091 << p->_v[0] <<" "
00092 << p->_v[1] <<" lineto stroke\n";
00093
00094
00095
00096
00097 }
00098
00099 typedef Point2dT<float> Point2df;
00100 typedef Point2dT<double> Point2dd;
00101
00102 };
00103 //#include "Point2dT.cpp"
00104 #endif /* !POINT2DT_H_ */
00105
Superior

Tenemos 39 visitantes y ningun miembro en Línea