Coefficient matrix A for slope(direction).
| 589 | |
| 590 | |
| 591 | class AngleTable(GeometricTable): |
| 592 | """Coefficient matrix A for slope(direction).""" |
| 593 | |
| 594 | def __init__(self, name: str = ''): |
| 595 | name = name or 'pi' |
| 596 | super().__init__(name) |
| 597 | self.pi = self.const |
| 598 | |
| 599 | def modulo(self, e: dict[str, float]) -> dict[str, float]: |
| 600 | e = strip(e) |
| 601 | if self.pi not in e: |
| 602 | return super().modulo(e) |
| 603 | |
| 604 | e[self.pi] = e[self.pi] % 1 |
| 605 | return strip(e) |
| 606 | |
| 607 | def add_para( |
| 608 | self, d1: gm.Direction, d2: gm.Direction, dep: pr.Dependency |
| 609 | ) -> None: |
| 610 | return self.add_const_angle(d1, d2, 0, dep) |
| 611 | |
| 612 | def add_const_angle( |
| 613 | self, d1: gm.Direction, d2: gm.Direction, ang: float, dep: pr.Dependency |
| 614 | ) -> None: |
| 615 | if ang and d2._obj.num > d1._obj.num: # pylint: disable=protected-access |
| 616 | d1, d2 = d2, d1 |
| 617 | ang = 180 - ang |
| 618 | |
| 619 | d1, d2 = self.get_name([d1, d2]) |
| 620 | |
| 621 | num, den = simplify(ang, 180) |
| 622 | ang = frac(int(num), int(den)) |
| 623 | return super().add_eq3(d1, d2, ang, dep) |
| 624 | |
| 625 | def add_eqangle( |
| 626 | self, |
| 627 | d1: gm.Direction, |
| 628 | d2: gm.Direction, |
| 629 | d3: gm.Direction, |
| 630 | d4: gm.Direction, |
| 631 | dep: pr.Dependency, |
| 632 | ) -> None: |
| 633 | """Add the inequality d1-d2=d3-d4.""" |
| 634 | # Use string as variables. |
| 635 | l1, l2, l3, l4 = [d._obj.num for d in [d1, d2, d3, d4]] # pylint: disable=protected-access |
| 636 | d1, d2, d3, d4 = self.get_name([d1, d2, d3, d4]) |
| 637 | ang1 = {d1: 1, d2: -1} |
| 638 | ang2 = {d3: 1, d4: -1} |
| 639 | |
| 640 | if l2 > l1: |
| 641 | ang1 = plus({self.pi: 1}, ang1) |
| 642 | if l4 > l3: |
| 643 | ang2 = plus({self.pi: 1}, ang2) |
| 644 | |
| 645 | ang12 = minus(ang1, ang2) |
| 646 | self.record_eq(d1, d2, d3, d4) |
| 647 | self.record_eq(d1, d3, d2, d4) |
| 648 |
nothing calls this directly
no outgoing calls
no test coverage detected