Back to index

texmacs  1.0.7.15
frame.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : frame.hpp
00004 * DESCRIPTION: coordinate frames
00005 * COPYRIGHT  : (C) 2003  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef FRAME_H
00013 #define FRAME_H
00014 #include "point.hpp"
00015 #include "matrix.hpp"
00016 
00017 class frame_rep: public abstract_struct {
00018 public:
00019   bool linear;
00020 public:
00021   inline frame_rep () { linear= false; }
00022   inline virtual ~frame_rep () {}
00023   virtual operator tree () = 0;
00024 
00025   virtual point direct_transform (point p) = 0;
00026   virtual point inverse_transform (point p) = 0;
00027   // a point p in frame f corresponds to f(p) = f->direct_transform(p)
00028   // in the parent frame of f
00029 
00030   virtual point jacobian (point p, point v, bool &error) = 0;
00031   virtual point jacobian_of_inverse (point p, point v, bool &error) = 0;
00032   // the Jacobian matrix at p applied to v
00033 
00034   virtual double direct_bound (point p, double eps) = 0;
00035   virtual double inverse_bound (point p, double eps) = 0;
00036   // direct_bound (p, eps) yields a delta such that for all p'
00037   // we have |p' - p| < delta => |f(p') - f(p)| < eps.
00038 
00039   inline double direct_scalar (double x) {
00040     return norm (direct_transform (point (x, 0))); }
00041   inline double inverse_scalar (double x) {
00042     return norm (inverse_transform (point (x, 0))); }
00043   // FIXME: used for grids, but error-prone. What is the idea?
00044 };
00045 
00046 class curve;
00047 class frame {
00048   ABSTRACT_NULL(frame);
00049   operator tree () { return (tree) *rep; }
00050   inline point operator () (point p) { return rep->direct_transform (p); }
00051   inline point operator [] (point p) { return rep->inverse_transform (p); }
00052   inline bool operator == (frame f) { return rep == f.rep; }
00053   inline bool operator != (frame f) { return rep != f.rep; }
00054   curve operator () (curve c);
00055   curve operator [] (curve c);
00056 };
00057 ABSTRACT_NULL_CODE(frame);
00058 
00059 // Transformations
00060 frame scaling (double magnify, point shift);
00061 frame rotation_2D (point center, double angle);
00062 frame affine_2D (matrix<double> m);
00063 
00064 // Operations on transformations
00065 frame operator * (frame f1, frame f2);
00066 frame invert (frame f);
00067 
00068 #endif // defined FRAME_H