vector2d 类型拥有 x 和 y 属性。 更多...
A
vector2d
类型拥有
x
and
y
attributes, otherwise it is similar to the
vector3d
类型。
Properties of type
vector2d
have a zero vector as their default value. This has both
x
and
y
设为
0
.
See the documentation about the
vector3d
type for more information.
要创建
vector2d
value, specify it as a "x,y" string, or define the components individually, or compose it with the Qt.vector2d() function.
The vector2d type has the following idempotent functions which can be invoked in QML:
函数签名 | 描述 | 范例 |
---|---|---|
real dotProduct(vector2d other) |
Returns the scalar real result of the dot product of
this
vector2d with the
other
vector2d
|
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) |
Returns the vector2d result of multiplying
this
vector2d with the
other
vector2d
|
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) |
Returns the vector2d result of multiplying
this
vector2d with the scalar
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) |
Returns the vector2d result of the addition of
this
vector2d with the
other
vector2d
|
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) |
Returns the vector2d result of the subtraction of
other
vector2d from
this
vector2d
|
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() |
Returns the normalized form of
this
vector
|
var a = Qt.vector2d(1,2); var b = a . normalized(); console . log(b . toString()); // QVector2D(0.447214, 0.894427) |
real length() |
Returns the scalar real value of the length of
this
vector2d
|
var a = Qt.vector2d(1,2); var b = a . length(); console . log(b . toString()); // 2.23606797749979 |
vector3d toVector3d() |
Returns the vector3d result of converting
this
vector2d to a vector3d
|
var a = Qt.vector2d(1,2); var b = a . toVector3d(); console . log(b . toString()); // QVector3D(1, 2, 0) |
vector4d toVector4d() |
Returns the vector4d result of converting
this
vector2d to a vector4d
|
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) |
返回 true 若
this
vector2d is approximately equal to the
other
vector2d. The approximation will be true if each attribute of
this
is within
epsilon
of
other
。注意,
epsilon
is an optional argument, the default
epsilon
is 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 |
This value type is provided by the QtQuick 导入。
另请参阅 QML 值类型 .