Coefficient matrix A for position(point, line).
| 657 | |
| 658 | |
| 659 | class DistanceTable(GeometricTable): |
| 660 | """Coefficient matrix A for position(point, line).""" |
| 661 | |
| 662 | def __init__(self, name: str = ''): |
| 663 | name = name or '1:1' |
| 664 | self.merged = {} |
| 665 | self.ratios = set() |
| 666 | super().__init__(name) |
| 667 | |
| 668 | def pairs(self) -> Generator[tuple[str, str], None, None]: |
| 669 | l2vs = defaultdict(list) |
| 670 | for v in list(self.v2e.keys()): # pylint: disable=g-builtin-op |
| 671 | if v == self.const: |
| 672 | continue |
| 673 | l, p = v.split(':') |
| 674 | l2vs[l].append(p) |
| 675 | |
| 676 | for l, ps in l2vs.items(): |
| 677 | for p1, p2 in perm2(ps): |
| 678 | yield l + ':' + p1, l + ':' + p2 |
| 679 | |
| 680 | def name(self, l: gm.Line, p: gm.Point) -> str: |
| 681 | v = l.name + ':' + p.name |
| 682 | self.v2obj[v] = (l, p) |
| 683 | return v |
| 684 | |
| 685 | def map2obj(self, names: list[str]) -> list[gm.Point]: |
| 686 | return [self.v2obj[n][1] for n in names] |
| 687 | |
| 688 | def add_cong( |
| 689 | self, |
| 690 | l12: gm.Line, |
| 691 | l34: gm.Line, |
| 692 | p1: gm.Point, |
| 693 | p2: gm.Point, |
| 694 | p3: gm.Point, |
| 695 | p4: gm.Point, |
| 696 | dep: pr.Dependency, |
| 697 | ) -> None: |
| 698 | """Add that distance between p1 and p2 (on l12) == p3 and p4 (on l34).""" |
| 699 | if p2.num > p1.num: |
| 700 | p1, p2 = p2, p1 |
| 701 | if p4.num > p3.num: |
| 702 | p3, p4 = p4, p3 |
| 703 | |
| 704 | p1 = self.name(l12, p1) |
| 705 | p2 = self.name(l12, p2) |
| 706 | p3 = self.name(l34, p3) |
| 707 | p4 = self.name(l34, p4) |
| 708 | return super().add_eq4(p1, p2, p3, p4, dep) |
| 709 | |
| 710 | def get_all_eqs_and_why(self) -> Generator[Any, None, None]: |
| 711 | for x in super().get_all_eqs_and_why(True): |
| 712 | yield x |
| 713 | |
| 714 | # Now we figure out all the const ratios. |
| 715 | h2pairs = defaultdict(list) |
| 716 | for v1, v2 in self.pairs(): |
nothing calls this directly
no outgoing calls
no test coverage detected