Class Matrix4

الحزمة: @aspose/3d (v24.12.0)

Matrix4 يخزن مصفوفة تحويل 4×4 كمصفوفة مسطحة مكوّنة من 16 رقمًا بترتيب الصفوف. إنها النوع الخاص بـ Transform.transformMatrix و GlobalTransform.transformMatrix. يمكن الوصول إلى العناصر الفردية كـ m00m33 خصائص، أو عبر الفهرس باستخدام getItem(i) / setItem(i, v). Matrix4 يتم تصديره من @aspose/3d/utilities المسار الفرعي.

export class Matrix4
import { Matrix4 } from '@aspose/3d/utilities';

Example

أنشئ مصفوفة TRS مركبة وقم بتحليلها مرة أخرى إلى مكوّناتها.

import { Matrix4, Vector3, Quaternion } from '@aspose/3d/utilities';

const t = Matrix4.translate(new Vector3(5, 0, 0));
const r = Matrix4.rotate(Quaternion.fromEulerAngle(0, Math.PI / 4, 0));
const s = Matrix4.scale(new Vector3(2, 2, 2));

const trs = t.concatenate(r).concatenate(s);

const translation: any[] = [null];
const scaling: any[] = [null];
const rotation: any[] = [null];
trs.decompose(translation, scaling, rotation);

console.log(`Translation X: ${translation[0].x}`); // Translation X: 5
console.log(`Scale X: ${scaling[0].x.toFixed(4)}`); // Scale X: 2.0000

Example

ExampleExample
new Matrix4()ينشئ مصفوفة الهوية 4×4.
new Matrix4(matrix: number[])ينشئ مصفوفة من مصفوفة مكوّنة من 16 عنصر بترتيب الصف الرئيسي.
new Matrix4(...args: number[])ينشئ مصفوفة من 16 وسيطًا عدديًا منفردًا.

فئة مصدر الضوء.

ExampleExampleExample
Matrix4.identityMatrix4يرجع مصفوفة هوية جديدة.

Example

العناصر الـ 16 للمصفوفة يمكن الوصول إليها كخصائص مسماة منفردة m00, m01, m02, m03, m10, …, m33,، حيث أن الرقم الأول يمثل الصف والرقم الثاني يمثل العمود. جميعها قابلة للقراءة والكتابة.

ExampleExampleExample
m00m33numberعناصر المصفوفة الفردية (تخطيط الصف الرئيسي).
determinantnumber (للقراءة فقط)المحدد العددي للمصفوفة.

يرجع كواترنيون العكسي. يطرح استثناء إذا كان الكواترنيون طوله صفر.

Matrix4.translate(v)

ينشئ مصفوفة إزاحة صافية من Vector3,، أو من منفرد (tx, ty, tz) أرقام.

static translate(v: Vector3): Matrix4
static translate(tx: number, ty?: number, tz?: number): Matrix4

Example

import { Matrix4, Vector3 } from '@aspose/3d/utilities';

const m = Matrix4.translate(new Vector3(3, 0, 0));
console.log(`m03: ${m.m03}`); // m03: 3

Matrix4.scale(v)

ينشئ مصفوفة تحجيم صافية من Vector3,، أو من (sx, sy, sz) أرقام.

static scale(v: Vector3): Matrix4
static scale(sx: number, sy?: number, sz?: number): Matrix4

Matrix4.rotate(q)

ينشئ مصفوفة دوران من Quaternion,، أو من زاوية (بالراديان) ومحور Vector3.

static rotate(q: Quaternion): Matrix4
static rotate(angle: number, axis: Vector3): Matrix4

Example

import { Matrix4, Quaternion } from '@aspose/3d/utilities';

const q = Quaternion.fromEulerAngle(0, Math.PI / 2, 0);
const m = Matrix4.rotate(q);
console.log(`Rotation matrix m00: ${m.m00.toFixed(4)}`);
// Rotation matrix m00: 0.0000

Matrix4.rotateFromEuler(rx, ry, rz)

ينشئ مصفوفة دوران من زوايا أويلر بالراديان.

static rotateFromEuler(rx: number, ry?: number, rz?: number): Matrix4
static rotateFromEuler(v: Vector3): Matrix4

حمّل ملف OBJ واطبع عدد العقد الفرعية في جذر مخطط المشهد.

concatenate(m2)

يرجع حاصل ضرب المصفوفات this × m2. استخدم هذا لدمج التحويلات (طبق this أولاً، ثم m2).

concatenate(m2: Matrix4): Matrix4

Example

import { Matrix4, Vector3 } from '@aspose/3d/utilities';

const translate = Matrix4.translate(new Vector3(1, 0, 0));
const scale = Matrix4.scale(new Vector3(2, 2, 2));
const combined = translate.concatenate(scale);
console.log(`m03: ${combined.m03}`); // m03: 1

inverse()

يرجع معكوس هذه المصفوفة. يطرح استثناء إذا كانت المصفوفة مفردة (المحدد قريب من الصفر).

inverse(): Matrix4

transpose()

يعيد المتنقلة لهذه المصفوفة (تتحول الصفوف إلى أعمدة).

transpose(): Matrix4

normalize()

يعيد مصفوفة جديدة حيث يتم تعامد مصفوفة الدوران (المقاس 3×3 في الزاوية العليا اليسرى) عن طريق قسمة كل صف على طوله. يتم الحفاظ على عمود الإزاحة.

normalize(): Matrix4

decompose(translation, scaling, rotation)

يفكك هذه المصفوفة إلى مكونات الإزاحة، والتحجيم، والدوران. تُكتب النتائج في العنصر الأول من كل مصفوفة إخراج.

decompose(translation: any[], scaling: any[], rotation: any[]): void

Example

translation any[] — مصفوفة الإخراج. بعد الاستدعاء،, translation[0] هو كائن {x, y, z} مع الترجمة.

scaling any[] — مصفوفة الإخراج. بعد الاستدعاء،, scaling[0] هو كائن {x, y, z} مع عوامل القياس.

rotation any[] — مصفوفة الإخراج. بعد الاستدعاء،, rotation[0] هو كائن {w, x, y, z} مع مكوّنات رباعية الدوران.

Example

import { Matrix4, Vector3, Quaternion } from '@aspose/3d/utilities';

const m = Matrix4.translate(new Vector3(0, 5, 0));
const trans: any[] = [null], scale: any[] = [null], rot: any[] = [null];
m.decompose(trans, scale, rot);
console.log(`Y: ${trans[0].y}`); // Y: 5

setTRS(translation, rotation, scale)

يضبط هذه المصفوفة لتكون ناتج ترجمة، دوران، وتكبير. يمكن أن تكون المدخلات كائنات عادية مع x, y, zw للدوران) الحقول.

setTRS(translation: any, rotation: any, scale: any): void

toArray()

يعيد نسخة من المصفوفة الداخلية ذات 16 عنصرًا بترتيب الصفوف.

toArray(): number[]

getItem(index) / setItem(index, value)

الوصول إلى العنصر عبر الفهرس الخطي (0–15، بترتيب الصفوف).

getItem(key: number): number
setItem(key: number, value: number): void

equals(other)

Example true إذا كانت جميع العناصر الـ16 متساوية تمامًا.

equals(other: Matrix4): boolean
 العربية