En esta página

vector3d QML Value Type

un valor con los atributos x, y y z. Más información...

Import Statement: import QtQuick

Descripción detallada

El tipo ` vector3d ` hace referencia a un valor con los atributos ` x`, ` y` y ` z `.

Las propiedades de tipo « vector3d » tienen un vector nulo por defecto. Este tiene los atributos « x », « y » y « z » establecidos en « 0 ».

Para crear un valor de tipo « vector3d », especifícalo como una cadena «x,y,z»:

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

o con la función Qt.vector3d():

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

o como componentes separados x, y y z:

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

Cada atributo de un valor vector3d se almacena internamente como un número de coma flotante de precisión simple (float).

Al integrar con C++, ten en cuenta que cualquier valor QVector3D pasado a QML desde C++ se convierte automáticamente en un valor vector3d, y viceversa.

El tipo vector3d dispone de las siguientes funciones idempotentes que pueden invocarse en QML:

Firma de la funciónDescripciónEjemplo
vector3d crossProduct(vector3d other)Devuelve el vector3d resultante del producto cruzado del vector3 this con el vector3d other
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)Devuelve el resultado escalar de tipo real del producto escalar de this vector3d con el other vector3d
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(matriz4x4 matrix)Devuelve el vector3d resultante de transformar un vector3d d this e con la matriz matrix de 4x4, aplicada después del vector
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 otro)Devuelve el vector3d resultante de multiplicar un vector3d « this » por el vector3d « other ».
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(factor real)Devuelve el vector3d resultante de multiplicar un vector3d « this » por el escalar 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 más(vector3d otro)Devuelve el resultado vector3d de la suma del vector3d « this » con el vector3d « other »
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 menos(vector3d otro)Devuelve el vector3d resultante de la resta de un vector3d de tipo « other » de un vector3d de tipo « this »
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 normalizado()Devuelve la forma normalizada del vector this
var a = Qt.vector3d(1,2,3);
var b = a.normalized();
console.log(b.toString());
// QVector3D(0.267261, 0.534522, 0.801784)
real length()Devuelve el valor real escalar de la longitud de this vector3d
var a = Qt.vector3d(1,2,3);
var b = a.length();
console.log(b.toString()); // 3.7416573867739413
vector2d toVector2d()Devuelve el vector2d resultante de convertir un vector3d de this e en un vector2d
var a = Qt.vector3d(1,2,3);
var b = a.toVector2d();
console.log(b.toString()); // QVector2D(1, 2)
vector4d toVector4d()Devuelve el resultado vector4d de la conversión de un vector3d de « this » a un vector4d
var a = Qt.vector3d(1,2,3);
var b = a.toVector4d();
console.log(b.toString()); // QVector4D(1, 2, 3, 0)
bool fuzzyEquals(vector3d otro, real épsilon)Devuelve «true» si un vector3d de « this » es aproximadamente igual a un vector3d de « other ». La aproximación será verdadera si cada atributo de « this » está dentro de « epsilon » de « other ». Ten en cuenta que « epsilon » es un argumento opcional; el valor por defecto de « epsilon » es 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

Este tipo de valor se proporciona mediante la importación QtQuick.

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