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';

BoundingBoxExtent

ノードを 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

BoundingBoxExtent

BoundingBoxExtentBoundingBoxExtent
new Quaternion()単位クォータニオンを作成します (1, 0, 0, 0).
new Quaternion(w, x, y, z)明示的な成分から四元数を作成します。.

BoundingBoxExtent

BoundingBoxExtentBoundingBoxExtentBoundingBoxExtent
wnumberスカラー(実数)成分。単位回転四元数の場合、, w = cos(θ/2).
xnumberベクトル部の X 成分。.
ynumberベクトル部の Y 成分。.
znumberベクトル部の Z 成分。.
lengthnumber (読み取り専用)大きさ:: sqrt(w² + x² + y² + z²). 有効な回転四元数の場合、1.0 である必要があります。.

静的プロパティ

BoundingBoxExtentBoundingBoxExtentBoundingBoxExtent
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

BoundingBoxExtent

pitch number — X 軸周りの回転(ラジアン).

yaw number — Y軸周りの回転(ラジアン)。.

roll number — Z軸周りの回転(ラジアン)。.

あるいは、単一の Vector3 その x, y, z ピッチ、ヨー、ロールを保持します。.

BoundingBoxExtent

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

BoundingBoxExtent

angle number — 回転角(ラジアン)。.

axis Vector3 — 回転軸。正規化する必要はありません。.

BoundingBoxExtent

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)

方向ベクトルを回転させる最短弧のクォータニオンを作成します origdest.

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

Quaternion.slerp(t, v1, v2)

…間で球面線形補間を実行します v1v2 パラメータで t (0.0 = v1, 1.0 = v2).

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

BoundingBoxExtent

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()

単位長さにスケーリングされた新しいクォータニオンを返します。.

normalize(): Quaternion

conjugate()

共役を返します (w, -x, -y, -z).

conjugate(): Quaternion

inverse()

逆クォータニオンを返します。クォータニオンの長さがゼロの場合は例外をスローします。.

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

BoundingBoxExtent

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)

BoundingBoxExtent true すべての4つの成分が厳密に等しい場合。.

equals(other: Quaternion): boolean

toString()

次の形式の文字列を返します Quaternion(w, x, y, z).

toString(): string
 日本語