contrib/gel/pop/pop_point_2d.cxx

Go to the documentation of this file.
00001 // This is gel/pop/pop_point_2d.cxx
00002 #include "pop_point_2d.h"
00003 //:
00004 // \file
00005 #include <vcl_iostream.h>
00006 
00007 
00008 //: constructor
00009 pop_point_2d::pop_point_2d(pop_vertex *coordinate_system,vcl_vector<pop_parameter*> &params):
00010   vgl_point_2d<double>(params[0]->value_,params[1]->value_),
00011   pop_geometric_object(coordinate_system,params)
00012 {
00013   this->update();
00014 }
00015 
00016 pop_point_2d::pop_point_2d(pop_vertex *coordinate_system,double x, double y):
00017   vgl_point_2d<double>(x,y),
00018   pop_geometric_object(coordinate_system)
00019 {
00020 }
00021 
00022 
00023 //: destructor
00024 pop_point_2d::~pop_point_2d()
00025 {
00026 }
00027 
00028 
00029 //: this is the update method
00030 void pop_point_2d::update()
00031 {
00032   vgl_point_2d<double>::set(params_[0]->value_,params_[1]->value_);
00033 }
00034 
00035 //: compute the cost between to geometric objects
00036 double pop_point_2d::cost(pop_geometric_object *other)
00037 {
00038   pop_point_2d *p = other->cast_to_pop_point_2d();
00039 
00040   if (p->coordinate_system_ != this->coordinate_system_) {
00041     vcl_cout << "Warning the systems do not match\n";
00042   }
00043 
00044   if (p) {
00045     // the cost is the square distance between the two points
00046 
00047     double dx = this->x() - p->x();
00048     double dy = this->y() - p->y();
00049     return dx*dx + dy*dy;
00050   }
00051   return 0;
00052 }
00053 

Generated on Fri Aug 29 05:14:42 2008 for contrib/gel/pop by  doxygen 1.5.1