This class contains method to draw rectangle and find intersection point.
| 481 | |
| 482 | |
| 483 | class RotatedRectangle(object): |
| 484 | |
| 485 | """ |
| 486 | This class contains method to draw rectangle and find intersection point. |
| 487 | """ |
| 488 | |
| 489 | def __init__(self, c_x, c_y, width, height, angle): |
| 490 | self.c_x = c_x |
| 491 | self.c_y = c_y |
| 492 | self.w = width # pylint: disable=invalid-name |
| 493 | self.h = height # pylint: disable=invalid-name |
| 494 | self.angle = angle |
| 495 | |
| 496 | def get_contour(self): |
| 497 | """ |
| 498 | create contour |
| 499 | """ |
| 500 | w = self.w |
| 501 | h = self.h |
| 502 | c = shapely.geometry.box(-w / 2.0, -h / 2.0, w / 2.0, h / 2.0) |
| 503 | rc = shapely.affinity.rotate(c, self.angle) |
| 504 | return shapely.affinity.translate(rc, self.c_x, self.c_y) |
| 505 | |
| 506 | def intersection(self, other): |
| 507 | """ |
| 508 | Obtain a intersection point between two contour. |
| 509 | """ |
| 510 | return self.get_contour().intersection(other.get_contour()) |
no outgoing calls
no test coverage detected