Outward-pointing unit normal for an edge (a→b). For CCW rings (standard exterior), the outward direction is the right normal (dy, -dx). This is correct because CCW traversal has the interior on the left.
(a: [f64; 2], b: [f64; 2])
| 271 | /// normal (dy, -dx). This is correct because CCW traversal has the |
| 272 | /// interior on the left. |
| 273 | fn edge_outward_normal(a: [f64; 2], b: [f64; 2]) -> [f64; 2] { |
| 274 | let dx = b[0] - a[0]; |
| 275 | let dy = b[1] - a[1]; |
| 276 | let len = (dx * dx + dy * dy).sqrt().max(1e-12); |
| 277 | // Right normal: (dy, -dx) normalized — outward for CCW rings. |
| 278 | [dy / len, -dx / len] |
| 279 | } |
| 280 | |
| 281 | /// Direction angle (radians) from a to b. |
| 282 | fn direction(a: [f64; 2], b: [f64; 2]) -> f64 { |
no outgoing calls
no test coverage detected