00001 //$Header: /home/ben/Mapper/include/RCS/distance_constraint.h,v 6.4 2002/07/07 18:23:15 ben Exp $
00002 #ifndef DISTANCE_CONSTRAINT_H
00003 #define DISTANCE_CONSTRAINT_H
00004 // Copyright Benedict Adamson 2002.
00005 // This file is part of Mapper.
00006
00007 // Mapper is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 2 of the License, or
00010 // (at your option) any later version.
00011
00012 // Mapper is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 // GNU General Public License for more details.
00016
00017 // You should have received a copy of the GNU General Public License
00018 // along with Mapper; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020
00031 #include "assoc.h"
00032 #include "constraint.h"
00033
00034
00035
00039 class distance_constraint
00040 :public constraint
00041 {
00042 public: //Constructors and destructors.
00043
00072 distance_constraint(
00073 const double u,
00074 const double d
00075 );
00076
00077 virtual ~distance_constraint(void);
00078
00079 public: //Attributes
00080
00111 virtual void energy(
00112 const double tol,
00113 const vector< vector2 > &p,
00114 double &e, //output
00115 vector< vector2 > &dedp //output
00116 ) const;
00117
00125 inline double wanted_distance(void) const;
00126
00127 public: //Messages
00128
00144 void wanted_distance(
00145 const double d
00146 );
00147
00148 private: //State
00149
00150 double wanted_distance_;
00151
00152 friend void assoc(
00153 distance_constraint &c,
00154 vector2 &p0,
00155 vector2 &p1
00156 );
00157
00158 friend void unassoc(
00159 distance_constraint &c
00160 );
00161
00162 };
00163
00164
00165
00166 inline double distance_constraint::wanted_distance(void) const
00167 {
00168 //The expected separation of the two constrained points.
00169 return this->wanted_distance_;
00170 }
00171
00172
00173
00174 #endif