Apply a transform matrix to an array of points. Parameters ---------- trans : array, shape = (4, 4) | instance of Transform Transform matrix. pts : array, shape = (3,) | (n, 3) Array with coordinates for one or n points. move : bool If True (default), app
(trans, pts, move=True)
| 255 | |
| 256 | |
| 257 | def apply_trans(trans, pts, move=True): |
| 258 | """Apply a transform matrix to an array of points. |
| 259 | |
| 260 | Parameters |
| 261 | ---------- |
| 262 | trans : array, shape = (4, 4) | instance of Transform |
| 263 | Transform matrix. |
| 264 | pts : array, shape = (3,) | (n, 3) |
| 265 | Array with coordinates for one or n points. |
| 266 | move : bool |
| 267 | If True (default), apply translation. |
| 268 | |
| 269 | Returns |
| 270 | ------- |
| 271 | transformed_pts : shape = (3,) | (n, 3) |
| 272 | Transformed point(s). |
| 273 | """ |
| 274 | if isinstance(trans, dict): |
| 275 | trans = trans["trans"] |
| 276 | pts = np.asarray(pts) |
| 277 | if pts.size == 0: |
| 278 | return pts.copy() |
| 279 | |
| 280 | # apply rotation & scale |
| 281 | out_pts = np.dot(pts, trans[:3, :3].T) |
| 282 | # apply translation |
| 283 | if move: |
| 284 | out_pts += trans[:3, 3] |
| 285 | |
| 286 | return out_pts |
| 287 | |
| 288 | |
| 289 | def rotation(x=0, y=0, z=0): |