Calculate the y-intercept of this line when it is at the specified offset. If the offset is None this is exactly equivalent to y_intercept :param offset: the offset of this line for this calculations :type offset: :class:`pygorithm.geometry.
(self, offset)
| 357 | return "{} -> {}".format(self.start, self.end) |
| 358 | |
| 359 | def calculate_y_intercept(self, offset): |
| 360 | """ |
| 361 | Calculate the y-intercept of this line when it is at the |
| 362 | specified offset. |
| 363 | |
| 364 | If the offset is None this is exactly equivalent to y_intercept |
| 365 | |
| 366 | :param offset: the offset of this line for this calculations |
| 367 | :type offset: :class:`pygorithm.geometry.vector2.Vector2` or None |
| 368 | :returns: the y-intercept of this line when at offset |
| 369 | :rtype: :class:`numbers.Number` |
| 370 | """ |
| 371 | |
| 372 | if offset is None: |
| 373 | return self.y_intercept |
| 374 | |
| 375 | if self.vertical: |
| 376 | return None |
| 377 | # y = mx + b -> b = y - mx |
| 378 | return self.start.y + offset.y - self.slope * (self.start.x + offset.x) |
| 379 | |
| 380 | @staticmethod |
| 381 | def are_parallel(line1, line2): |
no outgoing calls