* get the direction between two points * @param {Number} x * @param {Number} y * @return {Number} direction
(x, y)
| 52062 | |
| 52063 | |
| 52064 | function getDirection(x, y) { |
| 52065 | if (x === y) { |
| 52066 | return DIRECTION_NONE; |
| 52067 | } |
| 52068 | |
| 52069 | if (abs(x) >= abs(y)) { |
| 52070 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT; |
| 52071 | } |
| 52072 | |
| 52073 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN; |
| 52074 | } |
| 52075 | /** |
| 52076 | * calculate the absolute distance between two points |
| 52077 | * @param {Object} p1 {x, y} |
no outgoing calls
no test coverage detected