| 148 | """Numerical line.""" |
| 149 | |
| 150 | def __init__( |
| 151 | self, |
| 152 | p1: Point = None, |
| 153 | p2: Point = None, |
| 154 | coefficients: tuple[int, int, int] = None, |
| 155 | ): |
| 156 | if p1 is None and p2 is None and coefficients is None: |
| 157 | self.coefficients = None, None, None |
| 158 | return |
| 159 | |
| 160 | a, b, c = coefficients or ( |
| 161 | p1.y - p2.y, |
| 162 | p2.x - p1.x, |
| 163 | p1.x * p2.y - p2.x * p1.y, |
| 164 | ) |
| 165 | |
| 166 | # Make sure a is always positive (or always negative for that matter) |
| 167 | # With a == 0, Assuming a = +epsilon > 0 |
| 168 | # Then b such that ax + by = 0 with y>0 should be negative. |
| 169 | if a < 0.0 or a == 0.0 and b > 0.0: |
| 170 | a, b, c = -a, -b, -c |
| 171 | |
| 172 | self.coefficients = a, b, c |
| 173 | |
| 174 | def parallel_line(self, p: Point) -> Line: |
| 175 | a, b, _ = self.coefficients |