HyperspaceExplorer 0.7.1
Projection.h
00001 /*
00002     Hyperspace Explorer - vizualizing higher-dimensional geometry
00003     Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #ifndef PROJECTION_H
00022 #define PROJECTION_H
00023 
00024 #include "Vector.h"
00025 #include "MultiDimensionalVector.h"
00026 #include "ViewpointList.h"
00027 #include "ArrayList.h"
00028 
00030 template <unsigned N, unsigned Nnew, unsigned P, typename NUM> class SimpleProjectionPolicy;
00031 
00033 
00039 template <unsigned N, unsigned Nnew, unsigned P, typename NUM = double, typename Policy = SimpleProjectionPolicy <N, Nnew, P, NUM> > class Projection {
00040 
00041   public:
00042 
00044     typedef ViewpointList< N, Nnew, NUM > PointList;
00046     typedef ArrayList< N-Nnew, NUM > DistanceList;
00048     typedef ArrayList< N-Nnew, bool > BoolList;
00049 
00051     Projection(const PointList &viewpoint, const PointList &eye,
00052                const DistanceList &screenDistance, const BoolList &depthCue4D);
00053 
00055     Projection(NUM scrW, NUM camW, bool depthCue4D);
00056 
00058     VecMath::MultiDimensionalVector< VecMath::Vector<Nnew, NUM>, P > project(
00059             const VecMath::MultiDimensionalVector< VecMath::Vector<N, NUM>, P > &values);
00060 
00061   private:
00062 
00064     void checkConsistency();
00066     void checkDimensions();
00067 
00069     PointList makeOriginViewPointList();
00071     PointList makeEyePointList(NUM camW);
00073     DistanceList makeScreenDistanceList(NUM scrW);
00075     BoolList makeDepthCueList(bool depthCue4D);
00076 
00078     PointList _viewpoint;
00080     PointList _eye;
00082     DistanceList _screen_distance;
00084     BoolList _depth_cue;
00085 
00086 };
00087 
00089 
00094 template <unsigned N, unsigned Nnew, unsigned P, typename NUM> class SimpleProjectionPolicy {
00095 
00096   public:
00097 
00099 
00106     SimpleProjectionPolicy(typename Projection<N, Nnew, P, NUM>::PointList viewpoint,
00107                            typename Projection<N, Nnew, P, NUM>::PointList eye,
00108                            typename Projection<N, Nnew, P, NUM>::DistanceList screen_distance,
00109                            typename Projection<N, Nnew, P, NUM>::BoolList depth_cue):
00110                            _viewpoint(viewpoint), _eye(eye),
00111                            _screen_distance(screen_distance), _depth_cue(depth_cue) { }
00112 
00114     VecMath::MultiDimensionalVector< VecMath::Vector<Nnew, NUM>, P > project(
00115         const VecMath::MultiDimensionalVector< VecMath::Vector<N, NUM>, P > &values);
00116 
00117   private:
00118 
00120     typename Projection<N, Nnew, P, NUM>::PointList _viewpoint;
00122     typename Projection<N, Nnew, P, NUM>::PointList _eye;
00124     typename Projection<N, Nnew, P, NUM>::DistanceList _screen_distance;
00126     typename Projection<N, Nnew, P, NUM>::BoolList _depth_cue;
00127 
00128 };
00129 
00131 
00136 template <unsigned N, unsigned Nnew, typename NUM> class SimpleProjectionPolicy<N, Nnew, 1, NUM> {
00137 
00138   public:
00139 
00141 
00148     SimpleProjectionPolicy(typename Projection<N, Nnew, 1, NUM>::PointList viewpoint,
00149                            typename Projection<N, Nnew, 1, NUM>::PointList eye,
00150                            typename Projection<N, Nnew, 1, NUM>::DistanceList screen_distance,
00151                            typename Projection<N, Nnew, 1, NUM>::BoolList depth_cue):
00152                            _viewpoint(viewpoint), _eye(eye),
00153                            _screen_distance(screen_distance), _depth_cue(depth_cue) { }
00154 
00156     VecMath::MultiDimensionalVector< VecMath::Vector<Nnew, NUM>, 1 > project(
00157         const VecMath::MultiDimensionalVector< VecMath::Vector<N, NUM>, 1 > &values);
00158 
00159   private:
00160 
00162     typename Projection<N, Nnew, 1, NUM>::PointList _viewpoint;
00164     typename Projection<N, Nnew, 1, NUM>::PointList _eye;
00166     typename Projection<N, Nnew, 1, NUM>::DistanceList _screen_distance;
00168     typename Projection<N, Nnew, 1, NUM>::BoolList _depth_cue;
00169 
00170 };
00171 
00173 
00178 template <unsigned N, typename NUM> class SimpleProjectionPolicy<N, N, 1, NUM> {
00179 
00180   public:
00181 
00183     SimpleProjectionPolicy(typename Projection<N, N, 1, NUM>::PointList,
00184                            typename Projection<N, N, 1, NUM>::PointList,
00185                            typename Projection<N, N, 1, NUM>::DistanceList,
00186                            typename Projection<N, N, 1, NUM>::BoolList) { }
00187 
00189     VecMath::MultiDimensionalVector< VecMath::Vector<N, NUM>, 1 > project(
00190         const VecMath::MultiDimensionalVector< VecMath::Vector<N, NUM>, 1 > &values) {
00191       return values;
00192     }
00193 
00194 };
00195 
00196 #endif // PROJECTION_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:15 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo