En esta página

vector4d QML Value Type

Un tipo vector4d tiene atributos x, y, z y w. Más...

Descripción detallada

Un tipo vector4d tiene atributos x, y, z y w, por lo demás es similar al tipo vector3d.

Las propiedades del tipo vector4d tienen un vector cero por defecto. Esto tiene x, y,z y w establecidos en 0.

Consulte la documentación sobre el tipo vector3d para obtener más información.

Para crear un valor vector4d, especifíquelo como una cadena "x,y,z,w", o defina los componentes individualmente, o compóngalo con la función Qt.vector4d().

El tipo vector4d tiene las siguientes funciones idempotentes que pueden invocarse en QML:

Función FirmaDescripciónEjemplo
real dotProduct(vector4d otro)Devuelve el resultado real escalar del producto punto de this vector4d con el other vector4d
var a = Qt.vector4d(1,2,3,4);
var b = Qt.vector4d(5,6,7,8);
var c = a.dotProduct(b);
console.log(c); // 70
vector4d times(matriz4x4 matriz)Devuelve el resultado vector4d de transformar this vector4d con el 4x4 matrix con la matriz aplicada post-vector
var a = Qt.vector4d(1,2,3,4);
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()); // QVector4D(120, 130, 140, 150)
vector4d veces(vector4d otro)Devuelve el vector4d resultado de multiplicar this vector4d con el other vector4d
var a = Qt.vector4d(1,2,3,4);
var b = Qt.vector4d(5,6,7,8);
var c = a.times(b);
console.log(c.toString()); // QVector4D(5, 12, 21, 32)
vector4d veces(factor real)Devuelve el resultado de multiplicar this vector4d por el escalar factor
var a = Qt.vector4d(1,2,3,4);
var b = 4.48;
var c = a.times(b);
console.log(c.toString()); // QVector3D(4.48, 8.96,
                                        13.44, 17.92)
vector4d plus(vector4d otro)Devuelve el vector4d resultado de la suma de this vector4d con el other vector4d
var a = Qt.vector4d(1,2,3,4);
var b = Qt.vector4d(5,6,7,8);
var c = a.plus(b);
console.log(c.toString()); // QVector4D(6, 8, 10, 12)
vector4d menos(vector4d otro)Devuelve el vector4d resultante de la resta de other vector4d de this vector4d
var a = Qt.vector4d(1,2,3,4);
var b = Qt.vector4d(5,6,7,8);
var c = a.minus(b);
console.log(c.toString()); // QVector4D(-4, -4, -4, -4)
vector4d normalizado()Devuelve la forma normalizada del vector this
var a = Qt.vector4d(1,2,3,4);
var b = a.normalized();
console.log(b.toString());
// QVector4D(0.182574, 0.365148, 0.547723, 0.730297)
longitud real()Devuelve el valor real escalar de la longitud de this vector3d
var a = Qt.vector4d(1,2,3,4);
var b = a.length();
console.log(b.toString()); // 5.477225575051661
vector2d toVector2d()Devuelve el vector2d resultante de convertir this vector4d en un vector2d
var a = Qt.vector4d(1,2,3,4);
var b = a.toVector2d();
console.log(b.toString()); // QVector2D(1, 2)
vector3d toVector3d()Devuelve el vector3d resultante de convertir this vector4d en un vector3d
var a = Qt.vector4d(1,2,3,4);
var b = a.toVector3d();
console.log(b.toString()); // QVector3D(1, 2, 3)
bool fuzzyEquals(vector4d otro, real epsilon)Devuelve true si this vector4d es aproximadamente igual a other vector4d. La aproximación será verdadera si cada atributo de this está dentro de epsilon de other. Tenga en cuenta que epsilon es un argumento opcional, el valor por defecto epsilon es 0.00001.
var a = Qt.vector4d(1,2,3,4);
var b = Qt.vector4d(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

Este tipo de valor es proporcionado por la importación QtQuick.

Véase también Tipos de valor 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.