Class Matrix4
패키지: @aspose/3d (v24.12.0)
Matrix4 4×4 변환 행렬을 행 우선 순서(row-major order)로 16개의 숫자로 구성된 평면 배열에 저장합니다. 이것은 다음 유형입니다 Transform.transformMatrix 및 GlobalTransform.transformMatrix. 개별 요소는 다음과 같이 접근할 수 있습니다 m00–m33 속성으로, 또는 인덱스를 통해 getItem(i) / setItem(i, v). Matrix4 는 다음에서 내보내집니다 @aspose/3d/utilities 하위 경로에서.
export class Matrix4import { Matrix4 } from '@aspose/3d/utilities';ImageRenderOptions
결합된 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
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions |
|---|---|
new Matrix4() | 4×4 단위 행렬을 생성합니다. |
new Matrix4(matrix: number[]) | 행 우선 순서(row-major order)로 16요소 배열에서 행렬을 생성합니다. |
new Matrix4(...args: number[]) | 16개의 개별 숫자 인수를 사용해 행렬을 생성합니다. |
정적 속성
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
Matrix4.identity | Matrix4 | 새로운 단위 행렬을 반환합니다. |
ImageRenderOptions
16개의 행렬 요소는 개별 명명된 속성으로 접근할 수 있습니다 m00, m01, m02, m03, m10, …, m33, 여기서 첫 번째 숫자는 행, 두 번째 숫자는 열을 나타냅니다. 모두 읽기 및 쓰기가 가능합니다.
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
m00–m33 | number | 개별 행렬 요소 (row-major 레이아웃). |
determinant | number (읽기 전용) | 행렬의 스칼라 행렬식. |
정적 메서드
Matrix4.translate(v)
순수 변환 행렬을 a 로부터 생성합니다 Vector3, 또는 개별 (tx, ty, tz) 숫자들.
static translate(v: Vector3): Matrix4
static translate(tx: number, ty?: number, tz?: number): Matrix4ImageRenderOptions
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)
순수 스케일링 행렬을 a 로부터 생성합니다. Vector3, 또는 개별 (sx, sy, sz) 숫자들.
static scale(v: Vector3): Matrix4
static scale(sx: number, sy?: number, sz?: number): Matrix4Matrix4.rotate(q)
회전 행렬을 a 로부터 생성합니다. Quaternion, 또는 각도(라디안)와 축으로부터 Vector3.
static rotate(q: Quaternion): Matrix4
static rotate(angle: number, axis: Vector3): Matrix4ImageRenderOptions
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인스턴스 메서드
concatenate(m2)
행렬 곱을 반환합니다. this × m2. 변환을 결합하는 데 사용합니다 (적용 this 먼저, 그 다음 m2).
concatenate(m2: Matrix4): Matrix4ImageRenderOptions
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()
Returns the inverse of this matrix. Throws if the matrix is singular (determinant near zero). → 이 행렬의 역행렬을 반환합니다. 행렬이 특이한 경우(행렬식이 거의 0에 가까운 경우) 예외를 발생시킵니다.
inverse(): Matrix4transpose()
Returns the transpose of this matrix (rows become columns). → 이 행렬의 전치를 반환합니다(행이 열이 됩니다).
transpose(): Matrix4normalize()
Returns a new matrix with the rotation (upper-left 3×3) sub-matrix orthonormalized by dividing each row by its length. The translation column is preserved. → 회전(좌상단 3×3) 부분 행렬을 각 행을 길이로 나누어 직교정규화한 새로운 행렬을 반환합니다. 변환 열은 그대로 유지됩니다.
normalize(): Matrix4decompose(translation, scaling, rotation)
Decomposes this matrix into translation, scaling, and rotation components. Results are written into the first element of each output array. → 이 행렬을 변환, 스케일링, 회전 구성 요소로 분해합니다. 결과는 각 출력 배열의 첫 번째 요소에 기록됩니다.
decompose(translation: any[], scaling: any[], rotation: any[]): voidImageRenderOptions
translation any[] — 출력 배열. 호출 후, translation[0] 는 객체입니다 {x, y, z} translation을 포함합니다.
scaling any[] — 출력 배열. 호출 후, scaling[0] 는 객체입니다 {x, y, z} scale factors를 포함합니다.
rotation any[] — 출력 배열. 호출 후, rotation[0] 객체이다 {w, x, y, z} 회전 쿼터니언 구성 요소와 함께.
ImageRenderOptions
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, z (및 w 회전용) 필드.
setTRS(translation: any, rotation: any, scale: any): voidtoArray()
Returns a copy of the internal 16-element row-major array. → 내부 16요소 행 우선 배열의 복사본을 반환합니다.
toArray(): number[]getItem(index) / setItem(index, value)
선형 인덱스(0–15, 행 우선 순서)로 요소에 접근합니다.
getItem(key: number): number
setItem(key: number, value: number): voidequals(other)
ImageRenderOptions true 모든 16개 요소가 정확히 동일한 경우.
equals(other: Matrix4): boolean