MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSym.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  PSym.h 2D-Symmetries for the Point structure
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
27 #ifndef PSYM_H
28 #define PSYM_H
29 
30 #include "Point.h"
31 #include "itype.h"
32 
33 namespace MFM {
34 
60  enum PointSymmetry {
61  PSYM_DEG000L, // x -> x, y -> y
62  PSYM_DEG090L, // x -> y, y ->-x
63  PSYM_DEG180L, // x ->-x, y ->-y
64  PSYM_DEG270L, // x ->-y, y -> x
65  PSYM_DEG000R, // x -> x, y ->-y
66  PSYM_DEG090R, // x -> y, y -> x
67  PSYM_DEG180R, // x ->-x, y -> y
68  PSYM_DEG270R, // x ->-y, y ->-x
69  PSYM_SYMMETRY_COUNT,
70  PSYM_NORMAL=PSYM_DEG000L,
71  PSYM_FLIPX=PSYM_DEG180R,
72  PSYM_FLIPY=PSYM_DEG000R,
73  PSYM_FLIPXY=PSYM_DEG180L
74  };
75 
80  template <PointSymmetry PSYM>
81  inline SPoint Map(const SPoint & in) ;
82 
83  template <> inline SPoint Map<PSYM_DEG000L>(const SPoint & in) { return SPoint( in.GetX(), in.GetY()); } // x -> x, y -> y
84  template <> inline SPoint Map<PSYM_DEG090L>(const SPoint & in) { return SPoint(-in.GetY(), in.GetX()); } // x -> y, y ->-x
85  template <> inline SPoint Map<PSYM_DEG180L>(const SPoint & in) { return SPoint(-in.GetX(),-in.GetY()); } // x ->-x, y ->-y
86  template <> inline SPoint Map<PSYM_DEG270L>(const SPoint & in) { return SPoint( in.GetY(),-in.GetX()); } // x ->-y, y -> x
87  template <> inline SPoint Map<PSYM_DEG000R>(const SPoint & in) { return SPoint( in.GetX(),-in.GetY()); } // x -> x, y ->-y
88  template <> inline SPoint Map<PSYM_DEG090R>(const SPoint & in) { return SPoint( in.GetY(), in.GetX()); } // x -> y, y -> x
89  template <> inline SPoint Map<PSYM_DEG180R>(const SPoint & in) { return SPoint(-in.GetX(), in.GetY()); } // x ->-x, y -> y
90  template <> inline SPoint Map<PSYM_DEG270R>(const SPoint & in) { return SPoint(-in.GetY(),-in.GetX()); } // x ->-y, y ->-x
91 
96  inline SPoint Map(const SPoint & in, const PointSymmetry psym, const SPoint & ifNone) {
97  switch (psym) {
98  case PSYM_DEG000L: return Map<PSYM_DEG000L>(in);
99  case PSYM_DEG090L: return Map<PSYM_DEG090L>(in);
100  case PSYM_DEG180L: return Map<PSYM_DEG180L>(in);
101  case PSYM_DEG270L: return Map<PSYM_DEG270L>(in);
102  case PSYM_DEG000R: return Map<PSYM_DEG000R>(in);
103  case PSYM_DEG090R: return Map<PSYM_DEG090R>(in);
104  case PSYM_DEG180R: return Map<PSYM_DEG180R>(in);
105  case PSYM_DEG270R: return Map<PSYM_DEG270R>(in);
106  default: return ifNone;
107  }
108  }
109 
110 } /* namespace MFM */
111 
112 #endif /*PSYM_H*/