88from typing_extensions import Self
99
1010from t4_devkit .common .converter import to_quaternion
11- from t4_devkit .typing import Matrix3x3 , Matrix4x4 , NDArray , Quaternion , Vector3
11+ from t4_devkit .typing import Matrix3x3 , Matrix4x4 , Quaternion , Vector3
1212
1313if TYPE_CHECKING :
1414 from t4_devkit .typing import Matrix4x4Like , RotationLike , Vector3Like
@@ -292,8 +292,7 @@ def rotate(self, *args, **kwargs) -> RotateItemLike:
292292 if {"position" } == set (inputs .keys ()):
293293 return np .matmul (self .rotation_matrix , inputs ["position" ])
294294 elif {"rotation" } == set (inputs .keys ()):
295- rotation_matrix : NDArray = inputs ["rotation" ].rotation_matrix
296- return np .matmul (self .rotation_matrix , rotation_matrix )
295+ return np .matmul (self .rotation_matrix , inputs ["rotation" ].rotation_matrix )
297296 elif {"matrix" } == set (inputs .keys ()):
298297 matrix : HomogeneousMatrix = deepcopy (inputs ["matrix" ])
299298 matrix .rotation = Quaternion (
@@ -413,13 +412,16 @@ def _format_transform_args(*args, **kwargs) -> dict[str, Any]:
413412 if "matrix" in kwargs :
414413 raise KeyError ("Cannot specify `position` and `matrix` at the same time." )
415414 elif "rotation" in kwargs :
416- return {"position" : kwargs ["position" ], "rotation" : kwargs ["rotation" ]}
415+ return {
416+ "position" : Vector3 (kwargs ["position" ]),
417+ "rotation" : to_quaternion (kwargs ["rotation" ]),
418+ }
417419 else :
418- return {"position" : kwargs ["position" ]}
420+ return {"position" : Vector3 ( kwargs ["position" ]) }
419421 elif "rotation" in kwargs :
420422 if "matrix" in kwargs :
421423 raise KeyError ("Cannot specify `rotation` and `matrix` at the same time." )
422- return {"rotation" : kwargs ["rotation" ]}
424+ return {"rotation" : to_quaternion ( kwargs ["rotation" ]) }
423425 elif "matrix" in kwargs :
424426 return {"matrix" : kwargs ["matrix" ]}
425427 else :
@@ -436,15 +438,15 @@ def _format_transform_args(*args, **kwargs) -> dict[str, Any]:
436438 arg0 = np .asarray (arg0 )
437439 if arg0 .ndim == 1 :
438440 if len (arg0 ) == 3 :
439- return {"position" : arg0 }
441+ return {"position" : Vector3 ( arg0 ) }
440442 elif len (arg0 ) == 4 :
441- return {"rotation" : arg0 }
443+ return {"rotation" : to_quaternion ( arg0 ) }
442444 else :
443445 raise ValueError (f"Unexpected argument shape: { arg0 .shape } ." )
444446 else :
445447 if not arg0 .shape != (3 , 3 ):
446448 raise ValueError (f"Unexpected argument shape: { arg0 .shape } ." )
447- return {"rotation" : arg0 }
449+ return {"rotation" : to_quaternion ( arg0 ) }
448450 elif num_kwargs == 1 :
449451 if "rotation" not in kwargs :
450452 raise KeyError ("Expected two arguments: position and rotation." )
@@ -453,7 +455,7 @@ def _format_transform_args(*args, **kwargs) -> dict[str, Any]:
453455 raise ValueError (f"Too much arguments { num_args + num_kwargs } ." )
454456 # >>> (position, rotation)
455457 elif num_args == 2 :
456- return {"position" : args [0 ], "rotation" : args [1 ]}
458+ return {"position" : Vector3 ( args [0 ]) , "rotation" : to_quaternion ( args [1 ]) }
457459 else :
458460 raise ValueError (f"Too much arguments { num_args + num_kwargs } ." )
459461
0 commit comments