Proto  3.2
Proto_CoordPermutation.H
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef _PROTO_COORD_PERMUTATION_
4 #define _PROTO_COORD_PERMUTATION_
5 
6 #include "Proto_Point.H"
7 #include "Proto_Array.H"
8 #include "Proto_Box.H"
9 
10 namespace Proto
11 {
12  /// @brief Defines discrete rotations in logically rectangular coordinate systems.
14  {
15  public:
16 
17  /// Trivial Permutation
18  inline static CoordPermutation identity();
19  /// Clockwise (-90* rotation) in the XY plane
20  inline static CoordPermutation cw(int a_coord = 2);
21  /// Counter-Clockwise (+90* rotation) in the XY plane
22  inline static CoordPermutation ccw(int a_coord = 2);
23  /// Invert all coordinates
24  inline static CoordPermutation reverse();
25  /// Rotate the plane containing two coordinates such that c0 -> c1
26  /**
27  * Note that swapping the order of the inputs reverses the direction or rotation.
28  */
29  inline static CoordPermutation rotatePlane(int a_c0, int a_c1);
30 
31  /// Default / Identity constructor
32  inline CoordPermutation();
33  /// Constructor
34  /** Syntax:
35  * <code>CoordPermutation p {{c0, c1, s}, {c0, c1, s}};</code>
36  * Which is meant to be read as "map coordinate c0 to coordinate c1 with
37  * an optional reflection s".
38  * Any coordinates omitted from the constructor are understood to be mapped
39  * through a positive identity
40  *
41  * Example: 2D rotation in 3D:
42  * <code>CoordPermutation rot{{0,1,1}, {1,0,-1}};</code>
43  * coord 0 -> +coord 1
44  * coord 1 -> -coord 0
45  * coord 2 -> +coord 2
46  */
47  inline CoordPermutation(std::initializer_list<Array<int, 3>> a_args);
48  inline CoordPermutation(std::initializer_list<Array<Point,2>> a_args);
49  inline CoordPermutation(std::vector<Array<int, 3>>& a_args);
50  inline void define(std::vector<Array<int, 3>>& a_args);
51  inline void defineMatrix(Array<Array<int, DIM>, DIM> a_matrix);
52  /// Direct Matrix Construction
53  //CoordPermutation(Array<Array<int, DIM>, DIM> a_matrix);
54 
55  /// Permute the coordinates of a Point
56  inline Point operator()(Point a_pt) const;
57 
58  /// Compute and return the inverse Permutation
59  inline CoordPermutation inverse() const;
60 
61  /// Rotate Cell
62  /**
63  Given a Point and it's containing Box in unrotated coordinates,
64  compute the Point associated with the same finite volume cell in rotated coordinates.
65  Note that because a finite-volume cell is designated by it's low corner, this function
66  is not the same as rotatePoint.
67  */
68  inline Point rotateCell(Point a_point, const Box& a_srcBox, const Box& a_dstBox) const;
69 
70  /// Rotate Point
71  /**
72  Given a Point and it's containing Box in unrotated coordinates,
73  compute the Point associated with the same Point (vertex) in rotated coordinates.
74 
75  */
76  inline Point rotatePoint(Point a_point, const Box& a_srcBox, const Box& a_dstBox) const;
77 
78  template< typename T, unsigned int C=1, unsigned int D=1, unsigned int E=1>
79  inline void rotateBuffer(T* srcData, T* dstData,
80  const Box& srcBox, const Box& dstBox) const;
81 
82  inline Array<Array<int, DIM>, DIM> matrix() const {return m_matrix; }
83 
84  inline bool operator==(const CoordPermutation& a_rhs) const;
85 
86  inline bool isIdentity() const;
87 
88  inline void print() const;
89 
90  inline void printMatrix() const;
91 
92 
93  private:
94  inline bool isValid() const; // checks if the permutation is valid
95 
96  Array<Array<int, DIM>, DIM> m_matrix; // discrete rotation matrix
97  };
98 
99  inline CoordPermutation operator*(const CoordPermutation& a_A, const CoordPermutation& a_B);
100 } // end namespace Proto
101 #endif //end include guard
CoordPermutation()
Default / Identity constructor.
static CoordPermutation cw(int a_coord=2)
Clockwise (-90* rotation) in the XY plane.
void printMatrix() const
Point operator()(Point a_pt) const
Direct Matrix Construction.
Defines discrete rotations in logically rectangular coordinate systems.
Definition: Proto_CoordPermutation.H:13
CoordPermutation inverse() const
Compute and return the inverse Permutation.
bool operator==(const CoordPermutation &a_rhs) const
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
void rotateBuffer(T *srcData, T *dstData, const Box &srcBox, const Box &dstBox) const
Array< Array< int, DIM >, DIM > matrix() const
Definition: Proto_CoordPermutation.H:82
void defineMatrix(Array< Array< int, DIM >, DIM > a_matrix)
static CoordPermutation identity()
Trivial Permutation.
Definition: Proto_Array.H:17
Array< Array< int, DIM >, DIM > m_matrix
Definition: Proto_CoordPermutation.H:96
ACCEL_DECORATION Array< T, N > & operator*(int scale, Array< T, N > &arr)
Premultiplication by a scalar int.
A templated constant size array object similar to std::array, but with the ability to be used inside ...
Definition: Proto_Array.H:28
Integer Valued Vector.
Definition: Proto_Point.H:24
Point rotateCell(Point a_point, const Box &a_srcBox, const Box &a_dstBox) const
Rotate Cell.
static CoordPermutation rotatePlane(int a_c0, int a_c1)
Rotate the plane containing two coordinates such that c0 -> c1.
static CoordPermutation ccw(int a_coord=2)
Counter-Clockwise (+90* rotation) in the XY plane.
Point rotatePoint(Point a_point, const Box &a_srcBox, const Box &a_dstBox) const
Rotate Point.
static CoordPermutation reverse()
Invert all coordinates.
void define(std::vector< Array< int, 3 >> &a_args)