A 3d , 4x4 transformation matrix. Used to move geometry in space. The provided "matrix" parameter may be None, a gp_GTrsf, or a nested list of values. If given a nested list, it is expected to be of the form: [[m11, m12, m13, m14], [m21, m22, m23, m24],
| 271 | |
| 272 | |
| 273 | class Matrix: |
| 274 | """A 3d , 4x4 transformation matrix. |
| 275 | |
| 276 | Used to move geometry in space. |
| 277 | |
| 278 | The provided "matrix" parameter may be None, a gp_GTrsf, or a nested list of |
| 279 | values. |
| 280 | |
| 281 | If given a nested list, it is expected to be of the form: |
| 282 | |
| 283 | [[m11, m12, m13, m14], |
| 284 | [m21, m22, m23, m24], |
| 285 | [m31, m32, m33, m34]] |
| 286 | |
| 287 | A fourth row may be given, but it is expected to be: [0.0, 0.0, 0.0, 1.0] |
| 288 | since this is a transform matrix. |
| 289 | """ |
| 290 | |
| 291 | wrapped: gp_GTrsf |
| 292 | |
| 293 | @overload |
| 294 | def __init__(self) -> None: |
| 295 | ... |
| 296 | |
| 297 | @overload |
| 298 | def __init__(self, matrix: Union[gp_GTrsf, gp_Trsf]) -> None: |
| 299 | ... |
| 300 | |
| 301 | @overload |
| 302 | def __init__(self, matrix: Sequence[Sequence[float]]) -> None: |
| 303 | ... |
| 304 | |
| 305 | def __init__(self, matrix=None): |
| 306 | |
| 307 | if matrix is None: |
| 308 | self.wrapped = gp_GTrsf() |
| 309 | elif isinstance(matrix, gp_GTrsf): |
| 310 | self.wrapped = matrix |
| 311 | elif isinstance(matrix, gp_Trsf): |
| 312 | self.wrapped = gp_GTrsf(matrix) |
| 313 | elif isinstance(matrix, (list, tuple)): |
| 314 | # Validate matrix size & 4x4 last row value |
| 315 | valid_sizes = all( |
| 316 | (isinstance(row, (list, tuple)) and (len(row) == 4)) for row in matrix |
| 317 | ) and len(matrix) in (3, 4) |
| 318 | if not valid_sizes: |
| 319 | raise TypeError( |
| 320 | "Matrix constructor requires 2d list of 4x3 or 4x4, but got: {!r}".format( |
| 321 | matrix |
| 322 | ) |
| 323 | ) |
| 324 | elif (len(matrix) == 4) and (tuple(matrix[3]) != (0, 0, 0, 1)): |
| 325 | raise ValueError( |
| 326 | "Expected the last row to be [0,0,0,1], but got: {!r}".format( |
| 327 | matrix[3] |
| 328 | ) |
| 329 | ) |
| 330 |
no outgoing calls