00001 //$Header: /home/ben/Mapper/include/RCS/constraint.h,v 6.4 2002/06/10 22:16:16 ben Exp $
00002 #ifndef CONSTRAINT_H
00003 #define 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 <vector>
00032
00033 #include "vector2.h"
00034
00035
00036
00051 class constraint
00052 {
00053 public: //Constructors and destructors.
00064 constraint(
00065 const double u
00066 );
00067
00068 virtual ~constraint(void);
00069
00070 public: //Attributes
00071
00094 double energy(
00095 const double tol
00096 ) const;
00097
00098
00099
00130 virtual void energy(
00131 const double tol,
00132 const vector< vector2 > &p,
00133 double &e, //output
00134 vector< vector2 > &dedp //output
00135 ) const = 0;
00136
00150 inline double uncertainty(void) const;
00151
00152 public: //Relationships
00153
00159 inline vector< vector2 * > &points(void);
00160
00167 inline const vector< vector2 * > &points(void) const;
00168
00169 public: //Messages
00170
00186 void uncertainty(
00187 const double u
00188 );
00189
00190 private: //State
00191
00192 double uncertainty_;
00193
00194 protected: //State
00198 vector< vector2 * > points_;
00199
00200 };
00201
00202
00203
00204 inline double constraint::uncertainty(void) const
00205 {
00206 //A measure of how loose the constraint is.
00207 return this->uncertainty_;
00208 }
00209
00210
00211
00212 inline vector< vector2 * > &constraint::points(void)
00213 {
00214 //The points whose position the constraint directly applies to.
00215 //Moving these points can change the energy of the constraint;
00216 //Moving anyother points never changes the ernegy of the constraint.
00217 return this->points_;
00218 }
00219
00220
00221
00222 inline const vector< vector2 * > &constraint::points(void) const
00223 {
00224 //The points whose position the constraint directly applies to.
00225 //Moving these points can change the energy of the constraint;
00226 //Moving anyother points never changes the ernegy of the constraint.
00227 return this->points_;
00228 }
00229
00230
00231
00232 #endif