Check if two lines are parallel. Parameters ---------- dx1, dy1, dx2, dy2 : float The gradients *dy*/*dx* of the two lines. tolerance : float The angular tolerance in radians up to which the lines are considered parallel. Returns ------- is_
(dx1, dy1, dx2, dy2, tolerance=1.e-5)
| 526 | |
| 527 | |
| 528 | def check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1.e-5): |
| 529 | """ |
| 530 | Check if two lines are parallel. |
| 531 | |
| 532 | Parameters |
| 533 | ---------- |
| 534 | dx1, dy1, dx2, dy2 : float |
| 535 | The gradients *dy*/*dx* of the two lines. |
| 536 | tolerance : float |
| 537 | The angular tolerance in radians up to which the lines are considered |
| 538 | parallel. |
| 539 | |
| 540 | Returns |
| 541 | ------- |
| 542 | is_parallel |
| 543 | - 1 if two lines are parallel in same direction. |
| 544 | - -1 if two lines are parallel in opposite direction. |
| 545 | - False otherwise. |
| 546 | """ |
| 547 | theta1 = np.arctan2(dx1, dy1) |
| 548 | theta2 = np.arctan2(dx2, dy2) |
| 549 | dtheta = abs(theta1 - theta2) |
| 550 | if dtheta < tolerance: |
| 551 | return 1 |
| 552 | elif abs(dtheta - np.pi) < tolerance: |
| 553 | return -1 |
| 554 | else: |
| 555 | return False |
| 556 | |
| 557 | |
| 558 | def get_parallels(bezier2, width): |
no outgoing calls
no test coverage detected
searching dependent graphs…