Apply an affine transformation to the points. Args: pt (np.ndarray): a 2 dimensional point to be transformed trans_mat (np.ndarray): 2x3 matrix of an affine transform Returns: np.ndarray: Transformed points.
(pt, trans_mat)
| 247 | |
| 248 | |
| 249 | def affine_transform(pt, trans_mat): |
| 250 | """Apply an affine transformation to the points. |
| 251 | |
| 252 | Args: |
| 253 | pt (np.ndarray): a 2 dimensional point to be transformed |
| 254 | trans_mat (np.ndarray): 2x3 matrix of an affine transform |
| 255 | |
| 256 | Returns: |
| 257 | np.ndarray: Transformed points. |
| 258 | """ |
| 259 | assert len(pt) == 2 |
| 260 | new_pt = np.array(trans_mat) @ np.array([pt[0], pt[1], 1.]) |
| 261 | |
| 262 | return new_pt |
| 263 | |
| 264 | |
| 265 | def _get_3rd_point(a, b): |