(Vector v)
| 101 | } |
| 102 | |
| 103 | public static Direction closest(Vector v) { |
| 104 | double m = Double.MAX_VALUE; |
| 105 | Direction s = null; |
| 106 | |
| 107 | for (Direction i : values()) { |
| 108 | Vector x = i.toVector(); |
| 109 | double g = x.dot(v); |
| 110 | |
| 111 | if (g < m) { |
| 112 | m = g; |
| 113 | s = i; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return s; |
| 118 | } |
| 119 | |
| 120 | public static Direction closest(Vector v, Direction... d) { |
| 121 | double m = Double.MAX_VALUE; |