GraceFt v2.3
开源图形引擎 EGE(Easy Graphics Engine) 的高层封装库
 
载入中...
搜索中...
未找到
GFt::Line< T > 模板类 参考

几何线模板类 更多...

#include <Line.hpp>

Public 成员函数

constexpr Line (const Point< T > &p1, const Point< T > &p2)
 构造函数
 
constexpr auto distance () const
 计算给定的两个锚定点之间的欧式距离
 
constexpr bool isCollinearWith (const Line< T > &other) const
 判断此直线是否与另一个直线共线
 
constexpr auto manhatten_distance () const
 计算给定的两个锚定点之间的曼哈顿距离
 
constexpr operator bool () const
 判断直线是否有效
 
template<typename U >
constexpr operator Line< U > () const
 类型转换函数模板
 
constexpr bool operator! () const
 逻辑非运算符重载
 
constexpr bool operator!= (const Line< T > &other) const
 判断两个直线对象是否不同
 
constexpr bool operator== (const Line< T > &other) const
 判断两个直线对象是否相同
 
constexpr Point< T > & P1 ()
 获取直线的锚定点1
 
constexpr const Point< T > & P1 () const
 获取直线的锚定点1的 const 版本
 
constexpr Point< T > & P2 ()
 获取直线的锚定点2
 
constexpr const Point< T > & P2 () const
 获取直线的锚定点2的 const 版本
 

友元

std::ostream & operator<< (std::ostream &os, const Line< T > &line)
 流操作运算符重载
 

详细描述

template<typename T>
requires std::is_arithmetic_v<T>
class GFt::Line< T >

几何线模板类

用于表示直线的类模板

模板参数
T点的坐标类型,要求为算术类型

构造及析构函数说明

◆ Line()

template<typename T >
GFt::Line< T >::Line ( const Point< T > & p1,
const Point< T > & p2 )
inlineconstexpr

构造函数

参数
p1直线上的一点
p2直线上的另一点

成员函数说明

◆ distance()

template<typename T >
auto GFt::Line< T >::distance ( ) const
inlineconstexpr

计算给定的两个锚定点之间的欧式距离

返回
两个锚定点之间的距离

◆ isCollinearWith()

template<typename T >
bool GFt::Line< T >::isCollinearWith ( const Line< T > & other) const
inlineconstexpr

判断此直线是否与另一个直线共线

参数
other另一个直线对象
返回
两个直线是否共线

◆ manhatten_distance()

template<typename T >
auto GFt::Line< T >::manhatten_distance ( ) const
inlineconstexpr

计算给定的两个锚定点之间的曼哈顿距离

返回
两个锚定点之间的距离

◆ operator bool()

template<typename T >
GFt::Line< T >::operator bool ( ) const
inlineexplicitconstexpr

判断直线是否有效

返回
直线是否有效

◆ operator Line< U >()

template<typename T >
template<typename U >
GFt::Line< T >::operator Line< U > ( ) const
inlineconstexpr

类型转换函数模板

模板参数
U目标类型
返回
转换后的直线对象

◆ operator!()

template<typename T >
bool GFt::Line< T >::operator! ( ) const
inlineconstexpr

逻辑非运算符重载

效果同 operator bool() const 的结果取反

返回
逻辑非运算结果

◆ operator!=()

template<typename T >
bool GFt::Line< T >::operator!= ( const Line< T > & other) const
inlineconstexpr

判断两个直线对象是否不同

参数
other另一个直线对象
返回
两个直线对象是否不同

◆ operator==()

template<typename T >
bool GFt::Line< T >::operator== ( const Line< T > & other) const
inlineconstexpr

判断两个直线对象是否相同

参数
other另一个直线对象
返回
两个直线对象是否相同

◆ P1() [1/2]

template<typename T >
Point< T > & GFt::Line< T >::P1 ( )
inlineconstexpr

获取直线的锚定点1

返回
直线的锚定点1

◆ P1() [2/2]

template<typename T >
const Point< T > & GFt::Line< T >::P1 ( ) const
inlineconstexpr

获取直线的锚定点1的 const 版本

返回
直线的锚定点1

◆ P2() [1/2]

template<typename T >
Point< T > & GFt::Line< T >::P2 ( )
inlineconstexpr

获取直线的锚定点2

返回
直线的锚定点2

◆ P2() [2/2]

template<typename T >
const Point< T > & GFt::Line< T >::P2 ( ) const
inlineconstexpr

获取直线的锚定点2的 const 版本

返回
直线的锚定点2

友元及相关符号说明

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream & os,
const Line< T > & line )
friend

流操作运算符重载

参数
os输出流对象
line直线对象
返回
输出流对象 os