Matrix4
Methods
Matrix4 는 4×4 이중 정밀도 행렬이며, 행 우선 순서(row-major order)로 저장된 16개의 요소(m00–m33). 이는 월드/로컬 변환 계산, 사용자 정의 투영, 그리고 노드 변환을 위치, 회전, 스케일로 분해하는 데 사용됩니다.
Methods: aspose.threed.utilities
from aspose.threed.utilities import Matrix4Methods
| Methods | Methods |
|---|---|
Matrix4() | 단위 행렬 |
Matrix4(m00, m01, ..., m33) | 명시적 16요소 생성자 (행 우선 순서) |
Matrix4(values) | 16개의 목록으로부터 생성 float 값들 |
요소 속성
요소들은 다음과 같이 명명됩니다 mRC 여기서 R 는 행(0–3)이며 C 은(는) 열(0–3)입니다. 예를 들어, m03 은(는) 행 0, 열 3입니다 (행렬이 변환을 인코딩할 때 X 변환). 모든 16개의 속성 (m00 부터 m33)은 읽고 쓸 수 있습니다.
행렬은 평면 인덱스로도 접근할 수 있습니다: mat[0]–mat[15].
계산된 속성
| Methods | Methods | Methods |
|---|---|---|
determinant | float | 행렬의 스칼라 행렬식 |
정적 팩토리 메서드
| Methods | 반환 타입 | Methods |
|---|---|---|
Matrix4.get_identity() | Matrix4 | 단위 행렬을 반환합니다 |
Matrix4.translate(tx, ty, tz) | Matrix4 | 변환 행렬; 또한 a 를 허용합니다 Vector3 또는 균일한 변환을 위한 단일 스칼라 |
Matrix4.scale(sx, sy, sz) | Matrix4 | Scale matrix; 또한 a 를 허용합니다 Vector3 또는 균일 스케일을 위한 단일 스칼라 |
Matrix4.rotate(angle, axis) | Matrix4 | Rotation matrix; 각도(라디안)와 로부터 회전 행렬 Vector3 축; 또한 a 를 허용합니다 Quaternion 단일 인수로 |
Matrix4.rotate_from_euler(rx, ry, rz) | Matrix4 | Rotation matrix; Euler 각도(라디안)로부터 회전 행렬; 또한 a 를 허용합니다 Vector3 |
인스턴스 메서드
| Methods | 반환 타입 | Methods |
|---|---|---|
concatenate(m2) | Matrix4 | 행렬 곱을 반환합니다 self × m2 |
normalize() | Matrix4 | 회전 축을 재정규화한 복사본을 반환합니다 (회전 열에서 스케일이 제거됨) |
transpose() | Matrix4 | 전치 행렬을 반환합니다 |
inverse() | Matrix4 | 역행렬을 반환합니다; 예외를 발생시킵니다 ValueError 행렬이 특이인 경우 |
decompose(translation, scaling, rotation) | None | TRS 구성 요소로 분해합니다. 결과는 단일 요소 리스트에 기록됩니다: translation[0] → Vector3, scaling[0] → Vector3, rotation[0] → Quaternion |
set_trs(translation, rotation, scale) | None | translation으로부터 행렬을 제자리에서 설정합니다 Vector3, rotation Quaternion 또는 Vector3 (Euler), 및 scale Vector3 |
to_array() | list[float] | 16개의 요소를 평면 리스트로 반환합니다. |
Methods
from aspose.threed.utilities import Matrix4, Vector3, Quaternion
import math
# Build a transform: translate (5, 0, 0), rotate 90 deg around Y, scale 2x
t = Matrix4.translate(5.0, 0.0, 0.0)
r = Matrix4.rotate(math.radians(90), Vector3(0, 1, 0))
s = Matrix4.scale(2.0, 2.0, 2.0)
# Combine: scale first, then rotate, then translate
combined = t.concatenate(r.concatenate(s))
# Decompose the result back into TRS
translation = [None]
scaling = [None]
rotation = [None]
combined.decompose(translation, scaling, rotation)
print(translation[0]) # Vector3(5.0, 0.0, 0.0)
print(scaling[0]) # Vector3(2.0, 2.0, 2.0)
# Retrieve from a node's global transform
from aspose.threed import Scene
scene = Scene()
node = scene.root_node.create_child_node("box")
node.transform.translation = Vector3(10.0, 0.0, 0.0)
world_mat = node.global_transform.transform_matrix
print(world_mat.m03) # 10.0 — translation X