Matrix4

Methods

Matrix4 הוא מטריצה של 4×4 ברמת דיוק כפולה המאוחסנת בסדר שורות עם 16 אלמנטים (m00m33). זה משמש לחישובי טרנספורמציות עולם/מקומיות, פרוייקציות מותאמות, ופירוק טרנספורמציות של צמתים לתרגום, סיבוב וקנה מידה.

Methods: aspose.threed.utilities

from aspose.threed.utilities import Matrix4

Methods

MethodsMethods
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].

תכונות מחושבות

MethodsMethodsMethods
determinantfloatהדטרמיננטה הסקלרית של המטריצה

מתודות יצרן סטטיות

Methodsסוג החזרהMethods
Matrix4.get_identity()Matrix4מחזיר מטריצה זהות
Matrix4.translate(tx, ty, tz)Matrix4מטריצת תרגום; מקבלת גם a Vector3 או סקלר יחיד לתרגום אחיד
Matrix4.scale(sx, sy, sz)Matrix4מטריצת קנה מידה; מקבלת גם a Vector3 או סקלר יחיד לקנה מידה אחיד
Matrix4.rotate(angle, axis)Matrix4מטריצת סיבוב מזווית (רדיאנים) ו Vector3 ציר; מקבל גם Quaternion כארגומנט יחיד
Matrix4.rotate_from_euler(rx, ry, rz)Matrix4מטריצת סיבוב מזוויות אוילר (רדיאנים); מקבל גם 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מגדיר את המטריצה במקום מהתרגום Vector3, סיבוב Quaternion או Vector3 (אוילר), וקנה מידה 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

ראה גם

 עברית