C
Qul::PlatformInterface::Point Class
class Qul::PlatformInterface::PointPoint 类使用整数精度定义平面上的点。更多内容...
| Header: | #include <platforminterface/point.h> |
| Since: | Qt Quick Ultralite (Platform) 1.5 |
公共函数
| Point() | |
| Point(Qul::PlatformInterface::coord_t xpos, Qul::PlatformInterface::coord_t ypos) | |
| bool | isNull() const |
| Qul::PlatformInterface::coord_t | manhattanLength() const |
| Qul::PlatformInterface::coord_t & | rx() |
| Qul::PlatformInterface::coord_t & | ry() |
| void | setX(Qul::PlatformInterface::coord_t x) |
| void | setY(Qul::PlatformInterface::coord_t y) |
| Qul::PlatformInterface::coord_t | x() const |
| Qul::PlatformInterface::coord_t | y() const |
| Qul::PlatformInterface::Point & | operator*=(Qul::PlatformInterface::coord_t factor) |
| Qul::PlatformInterface::Point & | operator*=(float factor) |
| Qul::PlatformInterface::Point & | operator+=(const Qul::PlatformInterface::Point &point) |
| Qul::PlatformInterface::Point & | operator-=(const Qul::PlatformInterface::Point &point) |
| Qul::PlatformInterface::Point & | operator/=(float divisor) |
静态公共成员
| Qul::PlatformInterface::coord_t | dotProduct(const Qul::PlatformInterface::Point &p1, const Qul::PlatformInterface::Point &p2) |
详细说明
点由 x 坐标和 y 坐标指定,可通过x() 和y() 函数访问这些坐标。 如果 x 和 y 都设置为 0,则isNull() 函数将返回true 。可以使用setX() 和setY() 函数设置(或更改)坐标,或者使用rx() 和ry() 函数,这些函数返回对坐标的引用(允许直接操作)。
Point 对象也可作为向量使用:加法和减法的定义与向量相同(每个分量分别相加)。Point 对象还可以被coord_t 或float 进行除法或乘法运算。
此外,Point类还提供了manhattanLength()函数,该函数可提供将Point对象视为向量时的长度近似值,且计算开销较低。Point对象可以进行比较。
另请参阅 Qul::PlatformInterface::PointF 。
成员函数文档
Point::Point()
构造原点,即坐标为 (0, 0) 的点
另请参阅 isNull()。
Point::Point(Qul::PlatformInterface::coord_t xpos, Qul::PlatformInterface::coord_t ypos)
根据给定的坐标(xpos ,ypos )构造一个点。
[static] Qul::PlatformInterface::coord_t Point::dotProduct(const Qul::PlatformInterface::Point &p1, const Qul::PlatformInterface::Point &p2)
返回p1 与p2 的点积。
bool Point::isNull() const
如果 x 和 y 坐标均设为 0,则返回 `true `;否则返回 `false`。
Qul::PlatformInterface::coord_t Point::manhattanLength() const
返回x()和y()的绝对值之和,这通常被称为从原点到该点的向量的“曼哈顿长度”。这是对真实长度的一种有用且计算快速的近似值。 “曼哈顿长度”这一传统名称的由来,是因为此类距离适用于只能在矩形网格上移动的旅行者,例如曼哈顿的街道。
Qul::PlatformInterface::coord_t &Point::rx()
返回该点的 x 坐标的引用。使用引用可以直接操作 x。
Qul::PlatformInterface::coord_t &Point::ry()
返回该点的 y 坐标的引用。通过引用,可以直接操作 y 坐标。
void Point::setX(Qul::PlatformInterface::coord_t x)
将该点的 x 坐标设置为给定的x 坐标。
void Point::setY(Qul::PlatformInterface::coord_t y)
将该点的 y 坐标设置为给定的y 坐标。
Qul::PlatformInterface::coord_t Point::x() const
返回该点的 x 坐标。
Qul::PlatformInterface::coord_t Point::y() const
返回该点的 y 坐标。
Qul::PlatformInterface::Point &Point::operator*=(Qul::PlatformInterface::coord_t factor)
将该点的坐标乘以给定的factor ,并返回对该点的引用。
这是一个重载函数。
另请参阅 operator/=()。
Qul::PlatformInterface::Point &Point::operator*=(float factor)
将该点的坐标乘以给定的factor ,并返回该点的引用。请注意,由于点以整数形式存储,结果将四舍五入到最接近的整数。如需浮点精度,请使用PointF 。
这是一个重载函数。
另请参阅 operator/=()。
Qul::PlatformInterface::Point &Point::operator+=(const Qul::PlatformInterface::Point &point)
将给定的point 添加到该点上,并返回该点的引用。
另请参阅 operator-=()。
Qul::PlatformInterface::Point &Point::operator-=(const Qul::PlatformInterface::Point &point)
从该点减去给定的point ,并返回该点的引用。
另请参阅 operator+=()。
Qul::PlatformInterface::Point &Point::operator/=(float divisor)
将 x 和 y 均除以给定的divisor ,并返回该点的引用。请注意,由于坐标点以整数形式存储,因此结果将四舍五入到最接近的整数。如需浮点精度,请使用PointF 。
另请参阅 operator*=()。
在某些 Qt 许可证下可用。
了解更多信息。