31 lines
639 B
C
31 lines
639 B
C
#pragma once
|
|
|
|
|
|
/**
|
|
* Every type of rotation that can be applied to an object in a 2D grid
|
|
*/
|
|
enum Rotation {
|
|
NONE,
|
|
CLOCKWISE,
|
|
DOUBLE,
|
|
COUNTERCLOCKWISE
|
|
};
|
|
|
|
|
|
/**
|
|
* Addition operator
|
|
* @return A rotation corresponding to doing both rotations
|
|
*/
|
|
inline Rotation operator+(const Rotation& left, const Rotation& right) {
|
|
return Rotation(((int) left + (int) right) % 4);
|
|
}
|
|
|
|
/**
|
|
* Additive assignation operator, rotates the left rotation by the right rotation
|
|
* @return A reference to the left rotation
|
|
*/
|
|
inline Rotation& operator+=(Rotation& left, const Rotation& right) {
|
|
left = left + right;
|
|
return left;
|
|
}
|