rpos::core::RectangleF类
RectangleF表示一个矩形,其坐标参数的类型为float。
头文件
rpos/core/detail/geometry_rectangle.h
适用于
- Slamware
- Mapper
构造器
/**
* 创建一个x,y,width,height都为0的矩形。
*/
RectangleF();
/**
* 创建一个位置和大小为指定值的矩形。
*/
RectangleF(Vector2f position, Vector2f size);
/**
* 创建一个位置和大小为指定值的矩形。
*/
RectangleF(float x, float y, float width, float height);
/**
* 拷贝构造函数。
*/
RectangleF(const RectangleF&);
运算符
/**
* 赋值运算符。
*/
RectangleF& operator=(const RectangleF&);
方法
/**
* 矩形的位置(左上角)。
*/
const Vector2f& position() const;
Vector2f& position();
/**
* 矩形的大小。
*/
const Vector2f& size() const;
Vector2f& size();
/**
* 矩形左上角的x 坐标。
*/
float x() const;
float& x();
/**
* 矩形左上角的y 坐标。
*/
float y() const;
float& y();
/**
* 矩形的宽度。
*/
float width() const;
float& width();
/**
* 矩形的高度。
*/
float height() const;
float& height();
/**
* 矩形左侧的x坐标。
*/
float left() const;
/**
* 矩形右侧的x坐标(right=x+width)。
*/
float right() const;
/**
* 矩形顶部的y坐标。
*/
float top() const;
/**
* 矩形底部的y坐标(bottom=y+height)。
*/
float bottom() const;
/**
* 判断点是否在矩形的范围内。
*/
bool contains(const Vector2i& point) const;
/**
* 判断点是否在矩形的范围内。
*/
bool contains(float px, float py) const;
/**
* 判断矩形是否是全空的(即width()<epsilon或height()<epsilon)。
*/
bool empty() const;
/**
* 判断目标矩形是否完全在本矩形的区域内。
*/
bool contains(const RectangleF& dest) const;
/**
* 计算本矩形和目标矩形合并的部分,并将本矩形设定为该合并部分矩形,如下图所示。
*/
void unionOf(const RectangleF& dest);
/**
* 判断本矩形和目标矩形是否相交。
*/
bool isIntersectionWith(const RectangleF & dest) const;
/**
* 计算本矩形和目标矩形的重合部分,并将本矩形设定为该重合部分矩形,如下图所示。
*/
void intersectionOf(const RectangleF & dest);
/**
* 计算本矩形的面积。
*/
float area() const;