Auf dieser Seite

vector3d QML Value Type

ein Wert mit den Attributen x, y und z. Mehr...

Import Statement: import QtQuick

Ausführliche Beschreibung

Der Typ „ vector3d “ bezieht sich auf einen Wert mit den Attributen „ x “, „ y “ und „ z “.

Eigenschaften vom Typ „ vector3d “ haben standardmäßig einen Nullvektor. Dabei sind die Attribute „ x “, „ y “ und „ z “ auf „ 0 “ gesetzt.

Um einen „ vector3d “-Wert zu erstellen, geben Sie ihn als „x,y,z“-Zeichenkette an:

Rotation { angle: 60; axis: "0,1,0" }

oder mit der Funktion ` Qt.vector3d()`:

Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) }

oder als separate Komponenten „ x “, „ y “ und „ z “:

Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 }

Jedes Attribut eines `vector3d`-Werts wird intern als Gleitkommazahl mit einfacher Genauigkeit (`float`) gespeichert.

Bei der Integration mit C++ ist zu beachten, dass jeder aus C++ an QML übergebene QVector3D -Wert automatisch in einen vector3d -Wert konvertiert wird und umgekehrt.

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

FunktionssignaturBeschreibungBeispiel
vector3d crossProduct(vector3d other)Gibt das „vector3d“-Ergebnis des Kreuzprodukts von „ this “ „vector3d“ mit „ other “ „vector3d“ zurück
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(4,5,6);
var c = a.crossProduct(b);
console.log(c.toString()); // QVector3D(-3, 6, -3)
real dotProduct(vector3d other)Gibt das skalare reelle Ergebnis des Skalarprodukts von this vector3d mit dem other vector3d zurück
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(4,5,6);
var c = a.dotProduct(b);
console.log(c); // 32
vector3d times(matrix4x4 matrix)Gibt das Ergebnis vom Typ „vector3d“ zurück, das durch die Transformation des „ this “-Vektors „vector3d“ mit der 4x4- matrix -Matrix entsteht, wobei die Matrix nach dem Vektor angewendet wird
var a = Qt.vector3d(1,2,3);
var b = Qt.matrix4x4(4,5,6,7,8,9,10,11,
                     12,13,14,15,16,17,18,19);
var c = a.times(b);
console.log(c.toString());
// QVector3D(0.774194, 0.849462, 0.924731)
vector3d times(vector3d other)Gibt das vector3d-Ergebnis der Multiplikation v this en vector3d mit dem other en vector3d zurück
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(4,5,6);
var c = a.times(b);
console.log(c.toString()); // QVector3D(4, 10, 18)
vector3d times(real factor)Gibt das vector3d-Ergebnis der Multiplikation des this -Vektors mit dem Skalar zurück factor
var a = Qt.vector3d(1,2,3);
var b = 4.48;
var c = a.times(b);
console.log(c.toString()); // QVector3D(4.48, 8.96, 13.44)
vector3d plus(vector3d other)Gibt das vector3d-Ergebnis der Addition von this vector3d mit dem other vector3d zurück
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(4,5,6);
var c = a.plus(b);
console.log(c.toString()); // QVector3D(5, 7, 9)
vector3d minus(vector3d other)Gibt das vector3d-Ergebnis der Subtraktion von „ other “ vector3d von „ this “ vector3d zurück
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(4,5,6);
var c = a.minus(b);
console.log(c.toString()); // QVector3D(-3, -3, -3)
vector3d normalized()Gibt die normierte Form von ` this ` zurück
var a = Qt.vector3d(1,2,3);
var b = a.normalized();
console.log(b.toString());
// QVector3D(0.267261, 0.534522, 0.801784)
real length()Gibt den skalaren realen Wert der Länge des Vektors „ this “ zurück
var a = Qt.vector3d(1,2,3);
var b = a.length();
console.log(b.toString()); // 3.7416573867739413
vector2d toVector2d()Gibt das vector2d-Ergebnis der Konvertierung von this vector3d in einen vector2d zurück
var a = Qt.vector3d(1,2,3);
var b = a.toVector2d();
console.log(b.toString()); // QVector2D(1, 2)
vector4d toVector4d()Gibt das vector4d-Ergebnis der Konvertierung von this vector3d in einen vector4d zurück
var a = Qt.vector3d(1,2,3);
var b = a.toVector4d();
console.log(b.toString()); // QVector4D(1, 2, 3, 0)
bool fuzzyEquals(vector3d other, real epsilon)Gibt „true“ zurück, wenn der „ this “-Vektor3d annähernd gleich dem „ other “-Vektor3d 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 für „ epsilon “ ist 0,00001.
var a = Qt.vector3d(1,2,3);
var b = Qt.vector3d(1.0001, 1.9998, 2.0001);
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.