このページでは

vector2d QML Value Type

vector2d 型には x および y 属性があります。詳細...

Import Statement: import QtQuick

詳細な説明

vector2d 型には、x およびy 属性があり、それ以外はvector3d 型と同様です。

vector2d 型のプロパティのデフォルト値はゼロベクトルです。これは、x とy の両方が0 に設定されています。

詳細については、vector3d 型に関するドキュメントを参照してください。

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

vector2d 型には、QML から呼び出すことができる以下の冪等関数があります:

関数のシグネチャ説明例
real dotProduct(vector2d other)this のvector2dとother のvector2dの内積の結果を、実数のスカラー値として返します
var a = Qt.vector2d(1,2);
var b = Qt.vector2d(3,4);
var c = a.dotProduct(b);
console.log(c); // 11
vector2d times(vector2d other)this のvector2dとother のvector2dを乗算した結果のvector2dを返します。
var a = Qt.vector2d(1,2);
var b = Qt.vector2d(3,4);
var c = a.times(b);
console.log(c.toString()); // QVector2D(3, 8)
vector2d times(real factor)this のvector2dとスカラーを乗算した結果のvector2dを返します。factor
var a = Qt.vector2d(1,2);
var b = 4.48;
var c = a.times(b);
console.log(c.toString()); // QVector2D(4.48, 8.96)
vector2d plus(vector2d other)this vector2d とother vector2d の加算の結果を vector2d として返します。vector2d plus(vector2d other)
var a = Qt.vector2d(1,2);
var b = Qt.vector2d(3,4);
var c = a.plus(b);
console.log(c.toString()); // QVector2D(4, 6)
vector2d minus(vector2d other)other vector2d からthis vector2d を引いた結果の vector2d を返します。
var a = Qt.vector2d(1,2);
var b = Qt.vector2d(3,4);
var c = a.minus(b);
console.log(c.toString()); // QVector2D(-2, -2)
vector2d normalized()this のvector2dの正規化された形式を返します。
var a = Qt.vector2d(1,2);
var b = a.normalized();
console.log(b.toString()); // QVector2D(0.447214, 0.894427)
real length()this vector2d の長さのスカラー実数値を返します。
var a = Qt.vector2d(1,2);
var b = a.length();
console.log(b.toString()); // 2.23606797749979
vector3d toVector3d()this ベクトル2dをベクトル3dに変換した結果をベクトル3dとして返します
var a = Qt.vector2d(1,2);
var b = a.toVector3d();
console.log(b.toString()); // QVector3D(1, 2, 0)
vector4d toVector4d()this vector2d を vector4d に変換した結果を vector4d として返します。
var a = Qt.vector2d(1,2);
var b = a.toVector4d();
console.log(b.toString()); // QVector4D(1, 2, 0, 0)
bool fuzzyEquals(vector2d other, real epsilon)this のvector2dがother のvector2dと近似的に等しい場合、trueを返します。this の各属性がother のepsilon 以内にある場合、この近似は真となります。epsilon はオプションの引数であり、デフォルトのepsilon は0.00001であることに注意してください。
var a = Qt.vector2d(1,2);
var b = Qt.vector2d(1.0001, 1.9998);
var c = a.fuzzyEquals(b);        // default epsilon
var d = a.fuzzyEquals(b, 0.005); // supplied epsilon
console.log(c + " " + d); // false true

この値型は、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.