* Calculate the difference between two directions * * @param d0 The first direction as the base * @param d1 The second direction as the offset from the base * @return The difference how the second direction drifts of the first one. */
| 66 | * @return The difference how the second direction drifts of the first one. |
| 67 | */ |
| 68 | inline DirDiff DirDifference(Direction d0, Direction d1) |
| 69 | { |
| 70 | assert(IsValidDirection(d0)); |
| 71 | assert(IsValidDirection(d1)); |
| 72 | /* Cast to uint so compiler can use bitmask. If the difference is negative |
| 73 | * and we used int instead of uint, further "+ 8" would have to be added. */ |
| 74 | return static_cast<DirDiff>((static_cast<uint>(d0) - static_cast<uint>(d1)) % 8); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Applies two differences together |
no test coverage detected