Class Quaternion

Class Quaternion

패키지: @aspose/3d (v24.12.0)

Quaternion 전체에 걸쳐 사용됩니다 @aspose/3d API에서 짐벌 락 없이 회전을 나타내기 위해 사용됩니다. 이는 다음이 반환하는 타입입니다 Transform.rotationGlobalTransform.rotation. 아이덴티티 쿼터니언 (1, 0, 0, 0) 는 회전이 없음을 나타냅니다. Quaternion 는 다음에서 내보내집니다 @aspose/3d/utilities 하위 경로에서.

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

ImageRenderOptions

노드를 Y축을 기준으로 90° 회전시킨 다음, 부드럽게 보간하여 아이덴티티 상태로 되돌립니다.

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

const scene = new Scene();
const node = scene.rootNode.createChildNode('spinner');

// 90° around Y
const q90 = Quaternion.fromEulerAngle(0, Math.PI / 2, 0);
node.transform.rotation = q90;

// Slerp halfway back to identity
const identity = Quaternion.IDENTITY;
const half = Quaternion.slerp(0.5, q90, identity);
console.log(`Half rotation W: ${half.w.toFixed(4)}`);
// Half rotation W: 0.9239

ImageRenderOptions

ImageRenderOptionsImageRenderOptions
new Quaternion()아이덴티티 쿼터니언을 생성합니다 (1, 0, 0, 0).
new Quaternion(w, x, y, z)명시적인 구성 요소로부터 쿼터니언을 생성합니다.

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptions
wnumber스칼라(실수) 구성 요소. 단위 회전 쿼터니언의 경우, w = cos(θ/2).
xnumber벡터 부분의 X 구성 요소.
ynumber벡터 부분의 Y 구성 요소.
znumber벡터 부분의 Z 구성 요소.
lengthnumber (읽기 전용)크기: sqrt(w² + x² + y² + z²). 유효한 회전 쿼터니언의 경우 1.0이어야 합니다.

정적 속성

ImageRenderOptionsImageRenderOptionsImageRenderOptions
Quaternion.IDENTITYQuaternion새로운 항등 쿼터니언을 반환합니다 (1, 0, 0, 0).

정적 메서드

Quaternion.fromEulerAngle(pitch, yaw, roll)

Euler 각(라디안)으로부터 쿼터니언을 생성합니다.

static fromEulerAngle(pitch: number, yaw: number, roll: number): Quaternion
static fromEulerAngle(vec: Vector3): Quaternion

ImageRenderOptions

pitch number — X축을 기준으로 라디안 단위 회전.

yaw number — Y축을 기준으로 라디안 단위 회전.

roll number — Z축을 기준으로 라디안 단위 회전.

— 또는 단일 값을 전달합니다 Vector3 — 그 x, y, z — 피치, 요, 롤을 보유합니다.

ImageRenderOptions

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

const q = Quaternion.fromEulerAngle(0, Math.PI / 4, 0); // 45° around Y
console.log(`W: ${q.w.toFixed(4)}`); // W: 0.9239

Quaternion.fromAngleAxis(angle, axis)

— 회전량을 나타내는 쿼터니언을 생성합니다 angle — 라디안 단위로 axis.

static fromAngleAxis(angle: number, axis: Vector3): Quaternion

ImageRenderOptions

angle number — 라디안 단위 회전 각도.

axis Vector3 — 회전 축. 정규화될 필요는 없습니다.

ImageRenderOptions

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

const axis = new Vector3(0, 1, 0);
const q = Quaternion.fromAngleAxis(Math.PI / 2, axis);
console.log(`Rotating 90° around Y — W: ${q.w.toFixed(4)}`);
// Rotating 90° around Y — W: 0.7071

Quaternion.fromRotation(orig, dest)

— 방향 벡터를 회전시키는 최단 호 쿼터니언을 생성합니다 orig — 로 dest.

static fromRotation(orig: Vector3, dest: Vector3): Quaternion

Quaternion.slerp(t, v1, v2)

— 사이에서 구면 선형 보간을 수행합니다 v1 — 와 v2 — 매개변수에서 t (0.0 = v1, 1.0 = v2).

static slerp(t: number, v1: Quaternion, v2: Quaternion): Quaternion

ImageRenderOptions

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

const start = Quaternion.fromEulerAngle(0, 0, 0);
const end = Quaternion.fromEulerAngle(0, Math.PI, 0);
const mid = Quaternion.slerp(0.5, start, end);
console.log(`Mid W: ${mid.w.toFixed(4)}`); // Mid W: 0.7071

Quaternion.interpolate(t, fromQ, toQ)

다음의 별칭: slerp. 구면 선형 보간을 수행합니다.

static interpolate(t: number, fromQ: Quaternion, toQ: Quaternion): Quaternion

인스턴스 메서드

normalize()

단위 길이로 스케일된 새로운 quaternion을 반환합니다.

normalize(): Quaternion

conjugate()

켤레를 반환합니다 (w, -x, -y, -z).

conjugate(): Quaternion

inverse()

역 quaternion을 반환합니다. quaternion의 길이가 0이면 예외를 발생시킵니다.

inverse(): Quaternion

dot(q)

쿼터니언과의 스칼라 내적을 반환합니다 q.

dot(q: Quaternion): number

concat(rhs)

쿼터니언 곱을 반환합니다 this * rhs, 먼저 적용한 후 결합 회전을 나타냅니다 this 그 다음에 rhs.

concat(rhs: Quaternion): Quaternion

eulerAngles()

라디안 단위의 오일러 각으로 표현된 회전을 반환합니다 Vector3(pitch, yaw, roll).

eulerAngles(): Vector3

ImageRenderOptions

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

const q = Quaternion.fromEulerAngle(0, Math.PI / 3, 0);
const euler = q.eulerAngles();
console.log(`Yaw: ${euler.y.toFixed(4)}`);
// Yaw: 1.0472  (= π/3)

toMatrix()

이 쿼터니언을 동등한 Matrix4 회전 행렬로 변환합니다.

toMatrix(): Matrix4

equals(other)

ImageRenderOptions true 네 구성 요소가 모두 정확히 동일한 경우.

equals(other: Quaternion): boolean

toString()

다음 형식의 문자열을 반환합니다 Quaternion(w, x, y, z).

toString(): string
 한국어