Point2dT.h

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 .
00021 
00022 
00023 *******************************************************************************/
00024 
00025 
00026 
00027 #ifndef POINT2DT_H_
00028 # define POINT2DT_H_
00029 
00030 
00031 #include 
00032 namespace LA{
00033 
00051 template
00052 class Point2dT : public Point{
00053  
00054  public:
00055    Point2dT():Point(2){};
00056    Point2dT(T x,T y):Point(2)
00057      {
00058       Point::_v[0] = x; 
00059       Point::_v[1] = y;
00060      }
00061    //explicit conversion
00062    template
00063      Point & operator=(const Point  & p){
00064                
00065      Point::_v[0] = p[0];
00066      Point::_v[1] = p[1];
00067      
00068      return *this;
00069    }
00070    
00071    template
00072      friend U operator^(const Point2dT &, const Point2dT &);
00073   
00074    T& X(){return Point::_v[0];}
00075    T& Y(){return Point::_v[1];}
00076    void lineto (Point2dT*);
00077    
00078 };
00079 
00080 
00081 template
00082 U operator^(const Point2dT & pt1, const Point2dT & pt2){
00083   return  pt1[0]*pt2[1] - pt1[1]*pt2[0]; 
00084 }
00085 
00086 template
00087 void Point2dT::lineto(Point2dT * p){
00088 
00089   cout << Point::_v[0] <<" "
00090        << Point::_v[1] <<" moveto "
00091        << p->_v[0] <<" "
00092        << p->_v[1] <<" lineto stroke\n";
00093 
00094 
00095 
00096 
00097 }
00098 
00099 typedef  Point2dT Point2df;
00100 typedef  Point2dT Point2dd;
00101 
00102 };
00103 //#include "Point2dT.cpp"
00104 #endif /* !POINT2DT_H_ */
00105