Repository navigation
Commit df4cf92
authored
Make Line3 relation tests invariant to Plücker scale (#232)
## Summary
`Line3.isparallel()` compared the raw cross product of Plücker direction
vectors to an absolute tolerance. Scaling either representation
therefore changed whether perpendicular lines were reported as parallel.
The same classification feeds `|`, `isintersecting()` / `^`, and
`commonperp()`.
- Compare unit directions in `isparallel()` so the threshold represents
angular separation.
- Normalize both Plücker moments in `isintersecting()` so its
reciprocal-product tolerance is independent of coordinate scale.
- Build `commonperp()` from the nearest point and the cross product of
unit directions. The previous expression could also produce invalid
Plücker coordinates for nonorthogonal skew lines at unit scale.
- Add regressions for small, large, and sign-reversed scalings, a
near-parallel tolerance, crossing and skew lines, and the nearest-point
geometry.
For example, lines through `(0, 0, 0)` along `(1e-8, 0, 0)` and through
`(0, 0, 1)` along `(0, 1e-8, 0)` are perpendicular; before this change
`isparallel()` returned `True`.
This branch is based on current `master` and does not contain the
separate `distance()` fix in #224. I checked `closest_to_line()` on the
included scaled nonparallel cases; it needs no change for this issue.
## Validation
- New regression tests failed against the original implementation, then
passed with the change.
- `pytest -q --disable-warnings`: **350 passed, 3 skipped** (Python
3.10).
- Black and `git diff --check`: passed.
- Additional local geometric sampling across valid scaled line pairs
agreed with the analytical common-perpendicular location to
floating-point precision.
Fixes #231.
Implementation and tests were prepared and validated with OpenAI Codex
assistance.
---------
Signed-off-by: 李永祺 <doribelove@gmail.com>1 parent a6a2f1d commit df4cf92
2 files changed
Lines changed: 74 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
696 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
697 | 704 | | |
698 | 705 | | |
699 | 706 | | |
| |||
715 | 722 | | |
716 | 723 | | |
717 | 724 | | |
718 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
719 | 734 | | |
720 | 735 | | |
721 | 736 | | |
| |||
1005 | 1020 | | |
1006 | 1021 | | |
1007 | 1022 | | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | 1023 | | |
1017 | | - | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1018 | 1029 | | |
1019 | 1030 | | |
1020 | 1031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
| |||
253 | 273 | | |
254 | 274 | | |
255 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
256 | 292 | | |
257 | 293 | | |
258 | 294 | | |
| |||
267 | 303 | | |
268 | 304 | | |
269 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
270 | 322 | | |
271 | 323 | | |
272 | 324 | | |
| |||
0 commit comments