このページでは

quaternion QML Value Type

クォータニオン型には、スカラー、x、y、z の属性があります。詳細...

Import Statement: import QtQuick

詳細な説明

quaternion 型には、scalar 、x 、y 、およびz という属性があります。

quaternion 値を作成するには、「scalar,x,y,z」という形式の文字列として指定するか、各成分を個別に定義するか、あるいは Qt.quaternion() 関数を使用して生成します。

クォータニオン型には、QML内で呼び出すことができる以下の冪等関数があります:

関数のシグネチャ説明例
real dotProduct(quaternion other)this のクォータニオンとother のクォータニオンの内積を、スカラー実数として返します
var a = Qt.quaternion(1,2,3,4);
var b = Qt.quaternion(5,6,7,8);
var c = a.dotProduct(b);
console.log(c); // 70
quaternion times(quaternion other)this のクォータニオンとother のクォータニオンを乗算した結果のクォータニオンを返します。これは、両方の回転を適用することに相当します。
var a = Qt.quaternion(1 / Math.sqrt(2), 1 / Math.sqrt(2), 0, 0);
var b = Qt.quaternion(1 / Math.sqrt(2), 0, 1 / Math.sqrt(2), 0);
var c = b.times(a);
console.log(c.toString()); // QQuaternion(0.5, 0.5, 0.5, -0.5)
vector3d times(vector3d vector)vector をthis クォータニオンで回転させた結果の vector3d を返します。
var a = Qt.quaternion(0.5,0.5,0.5,-0.5);
var b = Qt.vector3d(4,5,6);
var c = a.times(b);
console.log(c.toString()); // QVector3D(5, -6, -4)
四元数 times(実数因子)this のクォータニオンにスカラーを乗算した結果のクォータニオンを返します。factor
var a = Qt.quaternion(1,2,3,4);
var b = 4.48;
var c = a.times(b);
console.log(c.toString()); // QQuaternion(4.48, 8.96, 13.44, 17.92)
quaternion plus(quaternion other)this のクォータニオンとother のクォータニオンを加算した結果のクォータニオンを返します
var a = Qt.quaternion(1,2,3,4);
var b = Qt.quaternion(5,6,7,8);
var c = a.plus(b);
console.log(c.toString()); // QQuaternion(6, 8, 10, 12)
quaternion minus(quaternion other)other のクォータニオンからthis のクォータニオンを引いた結果のクォータニオンを返します
var a = Qt.quaternion(1,2,3,4);
var b = Qt.quaternion(5,6,7,8);
var c = a.minus(b);
console.log(c.toString()); // QQuaternion(-4, -4, -4, -4)
quaternion normalized()this のクォータニオンを正規化された単位形式で返します
var a = Qt.quaternion(1,2,3,4);
var b = a.normalized();
console.log(b.toString()); // QQuaternion(0.182574, 0.365148, 0.547723, 0.730297)
quaternion inverted()this クォータニオンの逆数返します
var a = Qt.quaternion(0.5,0.5,0.5,-0.5);
var b = a.inverted();
console.log(b.toString()); // QQuaternion(0.5, -0.5, -0.5, 0.5)
quaternion 共役()this のクォータニオンの共役を返します
var a = Qt.quaternion(1,2,3,4);
var b = a.conjugated()
console.log(b.toString()); // QQuaternion(1, -2, -3, -4)
real length()this のクォータニオンの長さのスカラー実数を返します
var a = Qt.quaternion(1,2,3,4);
var b = a.length();
console.log(b.toString()); // 5.477225575051661
vector3d toEulerAngles()this 四元数に対応する vector3d 形式のオイラー角(度単位)を返します
var a = Qt.quaternion(0.933012,0.25,-0.25,0.066987);
var b = a.toEulerAngles();
console.log(b.toString()); // QVector3D(30, -30, -4.28846e-05)
vector4d toVector4d()this のクォータニオンをvector4dに変換した結果をvector4dとして返します。
var a = Qt.quaternion(1,2,3,4);
var b = a.toVector4d();
console.log(b.toString()); // QVector4D(2, 3, 4, 1)
bool fuzzyEquals(quaternion other, real epsilon)this のクォータニオンがother のクォータニオンに近似的に等しい場合、trueを返します。この近似は、this の各属性がother のepsilon 以内にある場合に真となります。epsilon はオプションの引数であり、デフォルトのepsilon は0.00001であることに注意してください。
var a = Qt.quaternion(1,2,3,4);
var b = Qt.quaternion(1.0001, 1.9998, 2.0001, 3.9999);
var c = a.fuzzyEquals(b);        // default epsilon
var d = a.fuzzyEquals(b, 0.005); // supplied epsilon
console.log(c + " " + d); // false true

quaternion 型のプロパティのデフォルト値はQt.quaternion(1, 0, 0, 0) です。

この値型は、QtQuick インポートによって提供されます。

「QML 値型」も参照してください 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.