Quaternion

Methods

Quaternion 単位クォータニオンを表し、3D回転をエンコードするために使用されます。オイラー角とは異なり、クォータニオンはジンバルロックを回避し、滑らかに補間します。The Transform.rotation シーンノードのプロパティは a を保存します。 Quaternion.

コンポーネントは次のように保存されます。 (w, x, y, z) ここで w はスカラー部であり、 (x, y, z) はベクトル部を構成します。.

from aspose.threed.utilities import Quaternion
import math

# Identity quaternion (no rotation)
q = Quaternion()   # w=1, x=0, y=0, z=0

# Rotation of 90 degrees around the Y axis
q = Quaternion.from_euler_angle(0.0, math.radians(90), 0.0)

Methods: aspose.threed.utilities

from aspose.threed.utilities import Quaternion

Methods

MethodsMethods
Quaternion()単位クォータニオン (w=1, x=0, y=0, z=0)
Quaternion(w, x, y, z)明示的コンポーネントコンストラクタ

Methods

MethodsMethodsMethods
wfloatスカラー(実数)部
xfloatベクトル x 成分
yfloatベクトル y 成分
zfloatベクトルの Z 成分
lengthfloatクォータニオンの大きさ

静的ファクトリーメソッド

Methods戻り値の型Methods
Quaternion.from_euler_angle(pitch, yaw, roll)Quaternionラジアン単位のオイラー角(ピッチ=X、ヨー=Y、ロール=Z)から構築します。また、 Vector3 最初の引数として
Quaternion.from_angle_axis(angle, axis)Quaternion角度(ラジアン)と Vector3
Quaternion.from_rotation(orig, dest)Quaternion方向から最短弧回転 orig 方向への dest
Quaternion.interpolate(t, from_q, to_q)QuaternionSLERP 補間; t[0, 1]
Quaternion.slerp(t, v1, v2)Quaternion別名 interpolate

インスタンスメソッド

Methods戻り値の型Methods
normalize()Quaternion単位長さのコピーを返す
conjugate()Quaternion共役を返す (w, -x, -y, -z)
inverse()Quaternion乗法的逆元を返す;例外を送出する ValueError 長さがゼロの場合
dot(q)float別のクォータニオンとのドット積
concat(rhs)Quaternionハミルトン積(2つの回転の合成)
euler_angles()Vector3オイラー角(ラジアン)を抽出し、として Vector3(roll, pitch, yaw)
to_matrix(translation=None)Matrix44×4回転行列に変換する;オプションで平行移動を埋め込む Vector3
to_angle_axis(angle, axis)None角度(ラジアン)と軸に分解する;結果は単一要素リストに書き込まれる angle[0] そして axis[0]

Methods

from aspose.threed import Scene
from aspose.threed.utilities import Quaternion, Vector3
import math

scene = Scene()
node = scene.root_node.create_child_node("rotated_box")

# Rotate 45 degrees around the Y axis
angle = math.radians(45)
q = Quaternion.from_euler_angle(0.0, angle, 0.0)
node.transform.rotation = q

# SLERP between two rotations
q_start = Quaternion.from_euler_angle(0, 0, 0)
q_end   = Quaternion.from_euler_angle(0, math.pi, 0)
q_mid   = Quaternion.slerp(0.5, q_start, q_end)

# Convert to matrix (useful for manual transforms)
mat = q.to_matrix()

# Extract Euler angles back
angles = q.euler_angles()   # Vector3(roll, pitch, yaw)
print(math.degrees(angles.y))   # ~45.0

関連項目

 日本語