Auf dieser Seite

vector2d QML Value Type

Ein Typ „vector2d“ verfügt über die Attribute „x“ und „y“. Mehr...

Import Statement: import QtQuick

Ausführliche Beschreibung

Ein Typ „ vector2d “ verfügt über die Attribute „ x “ und „ y “; ansonsten entspricht er dem Typ „ vector3d “.

Eigenschaften vom Typ „ vector2d “ haben als Standardwert einen Nullvektor. Dabei sind sowohl „ x “ als auch „ y “ auf „ 0 “ gesetzt.

Weitere Informationen finden Sie in der Dokumentation zum Typ „ vector3d “.

Um einen „ vector2d “-Wert zu erstellen, geben Sie ihn als „x,y“-Zeichenkette an, definieren Sie die Komponenten einzeln oder setzen Sie ihn mit der Funktion Qt.vector2d() zusammen.

Der Typ `vector2d` verfügt über die folgenden idempotenten Funktionen, die in QML aufgerufen werden können:

FunktionssignaturBeschreibungBeispiel
real dotProduct(vector2d other)Gibt das skalare reelle Ergebnis des Skalarprodukts des Vektors ` this ` mit dem Vektor ` other ` zurück
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)Gibt das vector2d-Ergebnis der Multiplikation von this vector2d mit other vector2d zurück
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)Gibt das vector2d-Ergebnis der Multiplikation von this vector2d mit dem Skalar zurück 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)Gibt das vector2d-Ergebnis der Addition von this vector2d mit dem other vector2d zurück
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)Gibt das vector2d-Ergebnis der Subtraktion von other vector2d von this vector2d zurück
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()Gibt die normierte Form von ` this ` zurück.
var a = Qt.vector2d(1,2);
var b = a.normalized();
console.log(b.toString()); // QVector2D(0.447214, 0.894427)
real length()Gibt den skalaren reellen Wert der Länge von this vector2d zurück
var a = Qt.vector2d(1,2);
var b = a.length();
console.log(b.toString()); // 2.23606797749979
vector3d toVector3d()Gibt das vector3d-Ergebnis der Konvertierung von this vector2d in einen vector3d zurück
var a = Qt.vector2d(1,2);
var b = a.toVector3d();
console.log(b.toString()); // QVector3D(1, 2, 0)
vector4d toVector4d()Gibt das vector4d-Ergebnis der Konvertierung von „ this “ vector2d in einen vector4d zurück
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)Gibt „true“ zurück, wenn der this -Vektor2d annähernd gleich dem other -Vektor2d ist. Die Annäherung gilt als erfüllt, wenn jedes Attribut von this innerhalb von epsilon von other liegt. Beachten Sie, dass epsilon ein optionales Argument ist; der Standardwert epsilon beträgt 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

Dieser Werttyp wird durch den Import „ QtQuick “ bereitgestellt.

Siehe auch QML-Werttypen.

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