TpPoint 类
V0.2.1TpUtils
2025-11-14
介绍
点坐标处理工具类
基础信息
| 头文件: | include <TpPoint.h> |
|---|---|
| Cmake: | None |
| 发布版本: | V0.2.1 |
| 继承类: | |
| 派生类: |
Public 成员函数
| TpPoint() | 默认构造函数 | |
|---|---|---|
| TpPoint(const TpPoint &other) | 拷贝构造 | |
| TpPoint(int32_t xpos, int32_t ypos) | 带坐标参数的构造函数 | |
| ~TpPoint() | 析构函数 | |
| isNull() const | 判断点是否为空(即(0,0)) | |
| x() const | 获取x坐标 | |
| y() const | 获取y坐标 | |
| setX(int32_t x) | 设置x坐标 | |
| setY(int32_t y) | 设置y坐标 | |
| manhattanLength() const | 计算曼哈顿长度( | |
| TpPoint TpPoint::transposed | transposed() const noexcept | 交换x和y坐标 |
| rx() | 获取x坐标的引用(可修改) | |
| ry() | 获取y坐标的引用(可修改) | |
| const TpPoint & TpPoint::operator= | operator=(const TpPoint &p) | 拷贝运算符 |
| TpPoint & TpPoint::operator+= | operator+=(const TpPoint &p) | 点加法赋值 |
| TpPoint & TpPoint::operator-= | operator-=(const TpPoint &p) | 点减法赋值 |
| TpPoint & TpPoint::operator*= | operator*=(float factor) | 点乘以浮点数因子(赋值) |
| TpPoint & TpPoint::operator*= | operator*=(double factor) | 点乘以双精度浮点数因子(赋值) |
| TpPoint & TpPoint::operator*= | operator*=(int32_t factor) | 点乘以整数因子(赋值) |
| TpPoint & TpPoint::operator/= | operator/=(float divisor) | 点除以浮点数(赋值) |
| TpPoint & TpPoint::operator/= | operator/=(double divisor) | 点除以双精度浮点数(赋值) |
| TpPoint & TpPoint::operator/= | operator/=(int32_t divisor) | 点除以整数(赋值) |
| dotProduct(const TpPoint &p1, const TpPoint &p2) | 点积(静态函数) |
成员函数说明
TpPoint::TpPoint()
默认构造函数...
默认构造函数
TpPoint::TpPoint(const TpPoint &other)
拷贝构造...
拷贝构造
参数:other: 点信息
TpPoint::TpPoint(int32_t xpos, int32_t ypos)
带坐标参数的构造函数...
带坐标参数的构造函数
参数:xpos: x坐标值
参数:ypos: y坐标值
TpPoint::~TpPoint()
析构函数...
析构函数
bool TpPoint::isNull() const
判断点是否为空(即(0,0))...
判断点是否为空(即(0,0))
返回值:true-空点,false-非空点
int32_t TpPoint::x() const
获取x坐标...
获取x坐标
返回值:x坐标值
int32_t TpPoint::y() const
获取y坐标...
获取y坐标
返回值:y坐标值
void TpPoint::setX(int32_t x)
设置x坐标...
设置x坐标
参数:x: 新的x坐标值
void TpPoint::setY(int32_t y)
设置y坐标...
设置y坐标
参数:y: 新的y坐标值
int32_t TpPoint::manhattanLength() const
计算曼哈顿长度(|x|+|y|)...
计算曼哈顿长度(|x|+|y|)
返回值:曼哈顿长度
TpPoint TpPoint::transposed() const noexcept
交换x和y坐标...
交换x和y坐标
返回值:交换后的点
int32_t & TpPoint::rx()
获取x坐标的引用(可修改)...
获取x坐标的引用(可修改)
返回值:x坐标的引用
int32_t & TpPoint::ry()
获取y坐标的引用(可修改)...
获取y坐标的引用(可修改)
返回值:y坐标的引用
const TpPoint & TpPoint::operator=(const TpPoint &p)
拷贝运算符...
拷贝运算符
参数:others: 要拷贝的对象
返回值:当前点的引用
TpPoint & TpPoint::operator+=(const TpPoint &p)
点加法赋值...
点加法赋值
参数:p: 要加的点
返回值:当前点的引用
TpPoint & TpPoint::operator-=(const TpPoint &p)
点减法赋值...
点减法赋值
参数:p: 要减的点
返回值:当前点的引用
TpPoint & TpPoint::operator*=(float factor)
点乘以浮点数因子(赋值)...
点乘以浮点数因子(赋值)
参数:factor: 因子
返回值:当前点的引用
TpPoint & TpPoint::operator*=(double factor)
点乘以双精度浮点数因子(赋值)...
点乘以双精度浮点数因子(赋值)
参数:factor: 因子
返回值:当前点的引用
TpPoint & TpPoint::operator*=(int32_t factor)
点乘以整数因子(赋值)...
点乘以整数因子(赋值)
参数:factor: 因子
返回值:当前点的引用
TpPoint & TpPoint::operator/=(float divisor)
点除以浮点数(赋值)...
点除以浮点数(赋值)
参数:divisor: 除数
返回值:当前点的引用
TpPoint & TpPoint::operator/=(double divisor)
点除以双精度浮点数(赋值)...
点除以双精度浮点数(赋值)
参数:divisor: 除数
返回值:当前点的引用
TpPoint & TpPoint::operator/=(int32_t divisor)
点除以整数(赋值)...
点除以整数(赋值)
参数:divisor: 除数
返回值:当前点的引用
static int32_t TpPoint::dotProduct(const TpPoint &p1, const TpPoint &p2)
点积(静态函数)...
点积(静态函数)
参数:p1: 第一个点
参数:p2: 第二个点
返回值:点积结果
