quaternion QML Value Type

四元数型はスカラー、x、y、z属性を持つ。詳細...

詳細説明

quaternion 型は、scalarxyz 属性を持つ。

quaternion の値を作成するには、"scalar,x,y,z" の文字列として指定するか、コンポーネントを個別に定義するか、Qt.quaternion() 関数で合成します。

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

関数のシグネチャ説明
real dotProduct(quaternion other)this quaternion とother quaternion のドット積のスカラー実数結果を返す。
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)this のクォータニオンでvector を回転させた 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)
quaternion times(real factor)this quaternion にスカラーを乗じた quaternion の結果を返します。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(他の四元数)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)
四元数マイナス(四元数他)this quaternion からother quaternion を減算した quaternion の結果を返します。
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)
クォータニオン正規化()this quaternion の正規化された単位形式を返します。
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 quaternion の逆数を返します。
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)
共役四元数()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 に変換した結果を返します。
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 の四元数とほぼ等しい場合に真を返します。近似値は、this の各属性がotherepsilon 以内にある場合に真となります。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の値型も参照してください

© 2025 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.