vector3d QML Value Type | Qt Quick (original) (raw)

vector3d crossProduct(vector3d other)

Returns the vector3d result of the cross product of this vector3d with the other vector3d

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)

Returns the scalar real result of the dot product of this vector3d with the 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(matrix4x4 matrix)

Returns the vector3d result of transforming this vector3d with the 4x4 matrix with the matrix applied post-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 other)

Returns the vector3d result of multiplying this vector3d with the other vector3d

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)

Returns the vector3d result of multiplying this vector3d with the scalar 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)

Returns the vector3d result of the addition of this vector3d with the other vector3d

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)

Returns the vector3d result of the subtraction of other vector3d from this vector3d

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()

Returns the normalized form of this vector

var a = Qt.vector3d(1,2,3); var b = a.normalized(); console.log(b.toString()); // QVector3D(0.267261, 0.534522, 0.801784)

real length()

Returns the scalar real value of the length of this vector3d

var a = Qt.vector3d(1,2,3); var b = a.length(); console.log(b.toString()); // 3.7416573867739413

vector2d toVector2d()

Returns the vector2d result of converting this vector3d to a vector2d

var a = Qt.vector3d(1,2,3); var b = a.toVector2d(); console.log(b.toString()); // QVector2D(1, 2)

vector4d toVector4d()

Returns the vector4d result of converting this vector3d to a vector4d

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)

Returns true if this vector3d is approximately equal to the other vector3d. The approximation will be true if each attribute of this is within epsilon of other. Note that epsilon is an optional argument, the default epsilon is 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