equal
deleted
inserted
replaced
127 let right_intersection = Point::new( |
127 let right_intersection = Point::new( |
128 map_box.right(), |
128 map_box.right(), |
129 (map_box.right() - mid_point.x) * p.y / p.x + mid_point.y); |
129 (map_box.right() - mid_point.x) * p.y / p.x + mid_point.y); |
130 dist_right = (mid_point - right_intersection).integral_norm(); |
130 dist_right = (mid_point - right_intersection).integral_norm(); |
131 |
131 |
132 if p.dot(mid_point - left_intersection) < 0 { |
132 if p.x > 0 { |
133 std::mem::swap(&mut dist_left, &mut dist_right); |
133 std::mem::swap(&mut dist_left, &mut dist_right); |
134 } |
134 } |
135 } |
135 } |
136 |
136 |
137 if p.y != 0 { |
137 if p.y != 0 { |
145 let bottom_intersection = Point::new( |
145 let bottom_intersection = Point::new( |
146 (map_box.bottom() - mid_point.y) * p.x / p.y + mid_point.x, |
146 (map_box.bottom() - mid_point.y) * p.x / p.y + mid_point.x, |
147 map_box.bottom()); |
147 map_box.bottom()); |
148 let dr = (mid_point - bottom_intersection).integral_norm(); |
148 let dr = (mid_point - bottom_intersection).integral_norm(); |
149 |
149 |
150 if p.dot(mid_point - top_intersection) > 0 { |
150 if p.y < 0 { |
151 dist_left = min(dist_left, dl); |
151 dist_left = min(dist_left, dl); |
152 dist_right = min(dist_right, dr); |
152 dist_right = min(dist_right, dr); |
153 } else { |
153 } else { |
154 dist_left = min(dist_left, dr); |
154 dist_left = min(dist_left, dr); |
155 dist_right = min(dist_right, dl); |
155 dist_right = min(dist_right, dl); |