dl
dl::Math 命名空间参考

2维装箱算法 更多...

命名空间

namespace  RingX
 

函数

template<typename T>
constexpr bool IsOutRange (T x, T a, T b)
 判断数值是否越界(前闭后开)
 
constexpr float Radian2Angle (float radin)
 弧度转角度
 
constexpr float Angle2Radian (float angle)
 角度转弧度
 
constexpr void RangeRadian (std::array< float, 2 > &arr)
 
uint32_t ByteReverse (uint32_t x)
 翻转字节序
 
template<typename T>
constexpr T Pow (T x, T n)
 返回x的n次方
 
constexpr uint64_t Pow64 (uint64_t x, uint8_t n)
 
constexpr uint32_t Pow32 (uint32_t x, uint8_t n)
 
constexpr uint64_t CeilToPow2 (uint64_t &&x)
 
constexpr uint32_t CeilToPow2 (uint32_t &&x)
 
template<typename T>
T CeilToPow2 (const T &x)
 向上取2的幂次
 
float RSqrt (float x)
 返回平方根的倒数
 
template<size_t N>
void NormalizeFast (Array< float, N > &v)
 向量单位化,精度低速度快
 
template<IsUnsigned T0, IsSigned T1>
T0 AddU (T0 a, T1 b)
 无符号 加 有符号,防止小于0
 
template<IsUnsigned T0, IsSigned T1, size_t N>
void AddU (Array< T0, N > &a, const Array< T1, N > &b)
 无符号 加 有符号,负数转为0
 
template<IsUnsigned T0, IsSigned T1, size_t N>
Array< T0, NAddU (const Array< T0, N > &a, const Array< T1, N > &b)
 
template<IsUnsigned T0, IsSigned T1>
bool AddUCheck (T0 a, T1 b, T0 &ret)
 无符号 加 有符号,检查负数
 
template<IsUnsigned T0, IsSigned T1, size_t N>
bool AddUCheck (const Array< T0, N > &a, const Array< T1, N > &b, const Array< T0, N > &ret)
 无符号 加 有符号,检查负数
 
template<IsUnsigned T>
T SubU (T a, T b)
 无符号类型相减,负数转为0
 
template<IsUnsigned T0, IsSigned T1>
T0 SubU (T0 a, T1 b)
 无符号减有符号,结果负数转为0
 
template<IsUnsigned T, size_t N>
Array< T, NSubU (const Array< T, N > &a, const Array< T, N > &b)
 无符号类型相减,负数转为0
 
template<IsUnsigned T0, IsSigned T1, size_t N>
Array< T0, NSubU (const Array< T0, N > &a, const Array< T1, N > &b)
 无符号减有符号,负数转为0
 
template<IsUnsigned T>
T DisU (T a, T b)
 返回无符号类型的差值
 
template<IsUnsigned T, size_t N>
Array< T, NDisU (const Array< T, N > &a, const Array< T, N > &b)
 返回无符号类型的差值
 
template<typename T>
T DistancePow2 (const Array< T, 2 > &a)
 返回 向量 距离的平方
 
template<typename T>
T DistancePow2 (const Array< T, 3 > &a)
 
template<typename T>
T DistancePow2 (const Array< T, 4 > &a)
 
template<typename T>
T Distance (const Array< T, 2 > &a)
 
template<typename T>
T Distance (const Array< T, 3 > &a)
 
template<typename T>
T Distance (const Array< T, 4 > &a)
 
template<IsSigned T>
T DistancePow2 (const Array< T, 2 > &a, const Array< T, 2 > &b)
 返回 距离的平方
 
template<IsUnsigned T>
T DistancePow2U (const Array< T, 2 > &a, const Array< T, 2 > &b)
 返回 距离的平方
 
template<IsUnsigned T>
T DistanceU (const Array< T, 2 > &a, const Array< T, 2 > &b)
 返回 距离
 
template<IsSigned T, size_t N>
void Normalize (Array< T, N > &v)
 向量单位化
 
template<IsSigned T, size_t N>
Array< T, NNormalize (const Array< T, N > &v)
 
std::vector< PointUGetCircle (const Size &size, const PointU &xy, unsigned rad)
 返回圆形范围的节点,考虑越界
 
std::vector< PointGetCircle (const Point &xy, unsigned rad)
 返回圆形范围的节点,不考虑越界
 
constexpr double PI (unsigned n=1, unsigned d=1)
 返回PI的分数
 
constexpr float PIF (unsigned n=1, unsigned d=1)
 
template<IsReal T>
constexpr T AlignF (T x, T align)
 RGP资源下标转方向
 
template<IsUnsigned T>
constexpr T Align (T x, T align)
 对齐align的倍数
 
constexpr unsigned IsPow2 (unsigned x)
 是否2的幂
 
constexpr unsigned AlignPow2 (unsigned x, unsigned align)
 对齐align的倍数
 
constexpr unsigned div_found (unsigned n, unsigned d)
 无符号除法,返回四舍五入结果
 
constexpr unsigned div_found_fast (unsigned n, unsigned d)
 无符号除法,返回四舍五入结果
 
constexpr float OffsetOrder (float order, int u=1, int v=0, int w=0)
 偏移order
 
constexpr Float CrossProduct (const Position2 &a, const Position2 &b)
 叉乘(四指指向a,弯向b,大拇指指向c)
 
constexpr Position3 CrossProduct (const Position3 &a, const Position3 &b)
 
template<typename T, size_t N>
constexpr T DotProduct (const Array< T, N > &a, const Array< T, N > &b)
 点乘
 
Position4 Slerp (const Position4 &q0, const Position4 &q1, const Float &t)
 球面线性插值
 
template<typename C>
constexpr auto DistanceDiagonal (const C &p0, const C &p1)
 纹理区域转uv
 
std::vector< PointDrawLineLerp (const Point &p0, const Point &p1)
 线性插值 画线算法
 
std::vector< PointDrawLineBresenham (const Point &p0, const Point &p1)
 bresenham 画线算法
 
std::vector< PointDrawLineOrth (const Point &p0, const Point &p1)
 正交 画线算法
 
std::vector< PointDrawLineCover (const Point &p0, const Point &p1)
 覆盖 画线算法
 
void MergePath (std::list< Point > &list_pos)
 路径合并(网格路径)
 
template<typename F>
void MergePathDirect (std::list< Point > &list_pos, F func_pass)
 路径合并(网格路径)
 
template<typename T>
constexpr T GetQuadSize (const Array< T, 4 > &quad)
 返回 Quad 的大小
 
template<typename T>
constexpr Array< T, 3 > GetQuadTriangle0 (const Array< T, 4 > &quad)
 返回 Quad的三角形
 
template<typename T>
constexpr Array< T, 3 > GetQuadTriangle1 (const Array< T, 4 > &quad)
 
template<typename T>
constexpr bool IsRectValid (const Array< T, 4 > &rect)
 判断 矩形 是否有效
 
template<typename T>
constexpr bool IsRectEmpty (const Array< T, 4 > &rect)
 判断 矩形 是否空
 
template<typename T>
constexpr bool IsRectInSize (const Array< T, 4 > &rect, const Size &size)
 判断 矩形 在 大小 内,首先它必须是有效的矩形
 
constexpr bool IsXyInSize (const Point &xy, const Size &size)
 判断 点是否在大小内
 
constexpr bool IsXyInRect (const Point &xy, const Rect &rect)
 判断 点是否在矩形内
 
constexpr bool IsTriangle (const Triangle &triangle)
 判断是否三角形
 
constexpr bool IsDotInTriangle (const Position &dot, const Triangle &triangle)
 判断点是否在三角形内(包含边)
 
constexpr bool IsDotInQuad (const Position &dot, const Quad &quad)
 判断点是否在四边形内(包含边)
 
constexpr Position CreatePositionByRatioGoldW (Float w)
 判断点是否在凸四边形内
 
template<typename T, typename F>
void GetRectTrim (F func, Array< T, 4 > &rect)
 裁切图像、网格
 
template<typename T>
void ExtendRectLeft (T min_left, Array< T, 4 > &rect, T extend=1)
 向左拓展矩形
 
template<typename T>
void ExtendRectTop (T min_top, Array< T, 4 > &rect, T extend=1)
 向上拓展矩形
 
template<typename T>
void ExtendRectRight (T max_right, Array< T, 4 > &rect, T extend=1)
 向右拓展矩形
 
template<typename T>
void ExtendRectBottom (T max_bottom, Array< T, 4 > &rect, T extend=1)
 向下拓展矩形
 
template<typename T>
void ExtendRect (const Array< T, 4 > &rect_big, Array< T, 4 > &rect, T extend=1)
 拓展矩形
 
template<typename T>
void ExtendRect (const Array< T, 2 > &size, Array< T, 4 > &rect, T extend=1)
 拓展矩形
 
template<typename T>
void ExtendRectRB (const Array< T, 2 > &size, Array< T, 4 > &rect, T extend=1)
 向右下拓展矩形
 
unsigned GetCircleNumMax (unsigned rad)
 返回圆所占格子数(GetCircle函数使用)
 
constexpr double DegreesToRadians (double deg)
 将角度转为弧度
 
constexpr double RadiansToDegrees (double rad)
 将弧度转为角度
 
constexpr bool IsLeapYear (int year)
 
constexpr int GetMouthDayNum (int year, int mouth)
 
double GetSolarDeclination (int day)
 计算太阳赤纬(太阳直射点纬度)
 
double GetSolarElevation (double latitude, double declination)
 计算正午太阳高度角
 
int GetSeason (int day, double latitude)
 返回季节
 
double GetBaseTemperature (double latitude, int day)
 基于纬度估算海平面基准温度(℃)
 

变量

constexpr uint64_t ARRAY_POW2 []
 2的整数次幂列表
 
constexpr uint32_t ARRAY_POW2_32 []
 

详细描述

2维装箱算法

参数
[in]size箱子大小
map_size传入矩形的数组,失败返回剩余的矩形
[out]map_fet返回装入的矩形信息

函数说明

◆ AddU() [1/3]

template<IsUnsigned T0, IsSigned T1, size_t N>
void dl::Math::AddU ( Array< T0, N > & a,
const Array< T1, N > & b )

无符号 加 有符号,负数转为0

在文件 dl_math.h280 行定义.

◆ AddU() [2/3]

template<IsUnsigned T0, IsSigned T1, size_t N>
Array< T0, N > dl::Math::AddU ( const Array< T0, N > & a,
const Array< T1, N > & b )
nodiscard

在文件 dl_math.h288 行定义.

◆ AddU() [3/3]

template<IsUnsigned T0, IsSigned T1>
T0 dl::Math::AddU ( T0 a,
T1 b )

无符号 加 有符号,防止小于0

在文件 dl_math.h269 行定义.

◆ AddUCheck() [1/2]

template<IsUnsigned T0, IsSigned T1, size_t N>
bool dl::Math::AddUCheck ( const Array< T0, N > & a,
const Array< T1, N > & b,
const Array< T0, N > & ret )

无符号 加 有符号,检查负数

在文件 dl_math.h313 行定义.

◆ AddUCheck() [2/2]

template<IsUnsigned T0, IsSigned T1>
bool dl::Math::AddUCheck ( T0 a,
T1 b,
T0 & ret )

无符号 加 有符号,检查负数

在文件 dl_math.h299 行定义.

◆ Align()

template<IsUnsigned T>
T dl::Math::Align ( T x,
T align )
constexpr

对齐align的倍数

注解
注意,现在如果x为0,则返回align

在文件 dl_math.h593 行定义.

◆ AlignF()

template<IsReal T>
T dl::Math::AlignF ( T x,
T align )
constexpr

RGP资源下标转方向

向量 转 掩码

对齐align的倍数,并且x考虑负数

注解
注意,现在如果x为0,则返回align
负数向右对齐

在文件 dl_math.h564 行定义.

◆ AlignPow2()

unsigned dl::Math::AlignPow2 ( unsigned x,
unsigned align )
constexpr

对齐align的倍数

参数
[in]align必须是2的幂,否则返回0

在文件 dl_math.h617 行定义.

◆ Angle2Radian()

float dl::Math::Angle2Radian ( float angle)
constexpr

角度转弧度

在文件 dl_math.h91 行定义.

◆ ByteReverse()

uint32_t dl::Math::ByteReverse ( uint32_t x)
inline

翻转字节序

在文件 dl_math.h113 行定义.

◆ CeilToPow2() [1/3]

template<typename T>
T dl::Math::CeilToPow2 ( const T & x)
inline

向上取2的幂次

注解
bit_ceil很难触发常量表达式,但在计算变量时最快

在文件 dl_math.h214 行定义.

◆ CeilToPow2() [2/3]

uint32_t dl::Math::CeilToPow2 ( uint32_t && x)
constexpr

在文件 dl_math.h198 行定义.

◆ CeilToPow2() [3/3]

uint64_t dl::Math::CeilToPow2 ( uint64_t && x)
constexpr

在文件 dl_math.h183 行定义.

◆ CreatePositionByRatioGoldW()

Position dl::Math::CreatePositionByRatioGoldW ( Float w)
constexpr

判断点是否在凸四边形内

参数
[in]dot
[in]quad四边形(凸)

按宽生成黄金比例大小

在文件 dl_math.h939 行定义.

◆ CrossProduct() [1/2]

Float dl::Math::CrossProduct ( const Position2 & a,
const Position2 & b )
constexpr

叉乘(四指指向a,弯向b,大拇指指向c)

在文件 dl_math.h674 行定义.

◆ CrossProduct() [2/2]

Position3 dl::Math::CrossProduct ( const Position3 & a,
const Position3 & b )
constexpr

在文件 dl_math.h679 行定义.

◆ DegreesToRadians()

double dl::Math::DegreesToRadians ( double deg)
constexpr

将角度转为弧度

在文件 dl_math.h1301 行定义.

◆ Distance() [1/3]

template<typename T>
T dl::Math::Distance ( const Array< T, 2 > & a)

在文件 dl_math.h406 行定义.

◆ Distance() [2/3]

template<typename T>
T dl::Math::Distance ( const Array< T, 3 > & a)

在文件 dl_math.h411 行定义.

◆ Distance() [3/3]

template<typename T>
T dl::Math::Distance ( const Array< T, 4 > & a)

在文件 dl_math.h416 行定义.

◆ DistanceDiagonal()

template<typename C>
auto dl::Math::DistanceDiagonal ( const C & p0,
const C & p1 )
constexpr

纹理区域转uv

对角线距离(注意不是真的对角线,而是取宽高较大者)

在文件 dl_math.h728 行定义.

◆ DistancePow2() [1/4]

template<typename T>
T dl::Math::DistancePow2 ( const Array< T, 2 > & a)

返回 向量 距离的平方

在文件 dl_math.h389 行定义.

◆ DistancePow2() [2/4]

template<IsSigned T>
T dl::Math::DistancePow2 ( const Array< T, 2 > & a,
const Array< T, 2 > & b )

返回 距离的平方

注解
有符号版本

在文件 dl_math.h425 行定义.

◆ DistancePow2() [3/4]

template<typename T>
T dl::Math::DistancePow2 ( const Array< T, 3 > & a)

在文件 dl_math.h395 行定义.

◆ DistancePow2() [4/4]

template<typename T>
T dl::Math::DistancePow2 ( const Array< T, 4 > & a)

在文件 dl_math.h401 行定义.

◆ DistancePow2U()

template<IsUnsigned T>
T dl::Math::DistancePow2U ( const Array< T, 2 > & a,
const Array< T, 2 > & b )

返回 距离的平方

注解
无符号版本

在文件 dl_math.h434 行定义.

◆ DistanceU()

template<IsUnsigned T>
T dl::Math::DistanceU ( const Array< T, 2 > & a,
const Array< T, 2 > & b )

返回 距离

注解
无符号版本

在文件 dl_math.h445 行定义.

◆ DisU() [1/2]

template<IsUnsigned T, size_t N>
Array< T, N > dl::Math::DisU ( const Array< T, N > & a,
const Array< T, N > & b )

返回无符号类型的差值

在文件 dl_math.h375 行定义.

◆ DisU() [2/2]

template<IsUnsigned T>
T dl::Math::DisU ( T a,
T b )

返回无符号类型的差值

在文件 dl_math.h366 行定义.

◆ div_found()

unsigned dl::Math::div_found ( unsigned n,
unsigned d )
constexpr

无符号除法,返回四舍五入结果

参数
[in]n分子
[in]d分母

在文件 dl_math.h630 行定义.

◆ div_found_fast()

unsigned dl::Math::div_found_fast ( unsigned n,
unsigned d )
constexpr

无符号除法,返回四舍五入结果

注解
分子n过大会溢出,但效率更高
参数
[in]n分子
[in]d分母

在文件 dl_math.h643 行定义.

◆ DotProduct()

template<typename T, size_t N>
T dl::Math::DotProduct ( const Array< T, N > & a,
const Array< T, N > & b )
constexpr

点乘

在文件 dl_math.h692 行定义.

◆ DrawLineBresenham()

std::vector< Point > dl::Math::DrawLineBresenham ( const Point & p0,
const Point & p1 )

bresenham 画线算法

◆ DrawLineCover()

std::vector< Point > dl::Math::DrawLineCover ( const Point & p0,
const Point & p1 )

覆盖 画线算法

注解
直线经过的网格都包含(会穿过对角线)

◆ DrawLineLerp()

std::vector< Point > dl::Math::DrawLineLerp ( const Point & p0,
const Point & p1 )

线性插值 画线算法

◆ DrawLineOrth()

std::vector< Point > dl::Math::DrawLineOrth ( const Point & p0,
const Point & p1 )

正交 画线算法

注解
只能竖着或横着走

◆ ExtendRect() [1/2]

template<typename T>
void dl::Math::ExtendRect ( const Array< T, 2 > & size,
Array< T, 4 > & rect,
T extend = 1 )

拓展矩形

参数
[in]size区域大小(左上角0,0)
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1091 行定义.

◆ ExtendRect() [2/2]

template<typename T>
void dl::Math::ExtendRect ( const Array< T, 4 > & rect_big,
Array< T, 4 > & rect,
T extend = 1 )

拓展矩形

参数
[in]rect_big最大区域
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1077 行定义.

◆ ExtendRectBottom()

template<typename T>
void dl::Math::ExtendRectBottom ( T max_bottom,
Array< T, 4 > & rect,
T extend = 1 )

向下拓展矩形

参数
[in]max_bottom最大下方
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1065 行定义.

◆ ExtendRectLeft()

template<typename T>
void dl::Math::ExtendRectLeft ( T min_left,
Array< T, 4 > & rect,
T extend = 1 )

向左拓展矩形

参数
[in]min_left最小左侧
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1032 行定义.

◆ ExtendRectRB()

template<typename T>
void dl::Math::ExtendRectRB ( const Array< T, 2 > & size,
Array< T, 4 > & rect,
T extend = 1 )

向右下拓展矩形

参数
[in]size区域大小(左上角0,0)
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1104 行定义.

◆ ExtendRectRight()

template<typename T>
void dl::Math::ExtendRectRight ( T max_right,
Array< T, 4 > & rect,
T extend = 1 )

向右拓展矩形

参数
[in]max_right最大右侧
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1054 行定义.

◆ ExtendRectTop()

template<typename T>
void dl::Math::ExtendRectTop ( T min_top,
Array< T, 4 > & rect,
T extend = 1 )

向上拓展矩形

参数
[in]min_top最小上方
[in|out]rect 初始区域,返回拓展后的

在文件 dl_math.h1043 行定义.

◆ GetBaseTemperature()

double dl::Math::GetBaseTemperature ( double latitude,
int day )

基于纬度估算海平面基准温度(℃)

参数
[in]latitude当地纬度(度)
[in]day一年第几天
返回值
估算温度(℃)

◆ GetCircle() [1/2]

std::vector< Point > dl::Math::GetCircle ( const Point & xy,
unsigned rad )

返回圆形范围的节点,不考虑越界

参数
[in]rad传入0返回1个节点、传入1返回4个节点、传入2返回13个节点,依次类推

◆ GetCircle() [2/2]

std::vector< PointU > dl::Math::GetCircle ( const Size & size,
const PointU & xy,
unsigned rad )

返回圆形范围的节点,考虑越界

参数
[in]rad传入0返回1个节点、传入1返回4个节点、传入2返回13个节点,依次类推

◆ GetCircleNumMax()

unsigned dl::Math::GetCircleNumMax ( unsigned rad)
inline

返回圆所占格子数(GetCircle函数使用)

在文件 dl_math.h1112 行定义.

◆ GetMouthDayNum()

int dl::Math::GetMouthDayNum ( int year,
int mouth )
constexpr

在文件 dl_math.h1321 行定义.

◆ GetQuadSize()

template<typename T>
T dl::Math::GetQuadSize ( const Array< T, 4 > & quad)
constexpr

返回 Quad 的大小

在文件 dl_math.h804 行定义.

◆ GetQuadTriangle0()

template<typename T>
Array< T, 3 > dl::Math::GetQuadTriangle0 ( const Array< T, 4 > & quad)
constexpr

返回 Quad的三角形

注解
顺时针绕序,0为右上方

在文件 dl_math.h814 行定义.

◆ GetQuadTriangle1()

template<typename T>
Array< T, 3 > dl::Math::GetQuadTriangle1 ( const Array< T, 4 > & quad)
constexpr

在文件 dl_math.h819 行定义.

◆ GetRectTrim()

template<typename T, typename F>
void dl::Math::GetRectTrim ( F func,
Array< T, 4 > & rect )

裁切图像、网格

参数
[in]func不可以裁切 请返回true
[in|out]rect 初始区域,返回裁切后的

在文件 dl_math.h950 行定义.

◆ GetSeason()

int dl::Math::GetSeason ( int day,
double latitude )

返回季节

返回值
0.春季1.夏季 2.秋季 3.冬季

◆ GetSolarDeclination()

double dl::Math::GetSolarDeclination ( int day)

计算太阳赤纬(太阳直射点纬度)

参数
[in]day一年中的第几天(1月1日为1,12月31日为365)
返回值
赤纬角度(单位:度),范围-23.44° 到 +23.44°
注解
春分和秋分南北半球温度更一致(79、265)

◆ GetSolarElevation()

double dl::Math::GetSolarElevation ( double latitude,
double declination )

计算正午太阳高度角

参数
[in]latitude当地纬度(度,北正南负)
[in]declination太阳赤纬(度)
返回值
正午太阳高度角(度)

◆ IsDotInQuad()

bool dl::Math::IsDotInQuad ( const Position & dot,
const Quad & quad )
constexpr

判断点是否在四边形内(包含边)

参数
[in]dot
[in]quad四边形

在文件 dl_math.h920 行定义.

◆ IsDotInTriangle()

bool dl::Math::IsDotInTriangle ( const Position & dot,
const Triangle & triangle )
constexpr

判断点是否在三角形内(包含边)

参数
[in]dot
[in]triangle三角形

在文件 dl_math.h900 行定义.

◆ IsLeapYear()

bool dl::Math::IsLeapYear ( int year)
constexpr

在文件 dl_math.h1313 行定义.

◆ IsOutRange()

template<typename T>
bool dl::Math::IsOutRange ( T x,
T a,
T b )
constexpr

判断数值是否越界(前闭后开)

在文件 dl_math.h77 行定义.

◆ IsPow2()

unsigned dl::Math::IsPow2 ( unsigned x)
constexpr

是否2的幂

在文件 dl_math.h608 行定义.

◆ IsRectEmpty()

template<typename T>
bool dl::Math::IsRectEmpty ( const Array< T, 4 > & rect)
constexpr

判断 矩形 是否空

参数
[in]rect矩形

在文件 dl_math.h840 行定义.

◆ IsRectInSize()

template<typename T>
bool dl::Math::IsRectInSize ( const Array< T, 4 > & rect,
const Size & size )
constexpr

判断 矩形 在 大小 内,首先它必须是有效的矩形

参数
[in]rect矩形

在文件 dl_math.h851 行定义.

◆ IsRectValid()

template<typename T>
bool dl::Math::IsRectValid ( const Array< T, 4 > & rect)
constexpr

判断 矩形 是否有效

参数
[in]rect矩形
注解
空矩形也是有效的

在文件 dl_math.h830 行定义.

◆ IsTriangle()

bool dl::Math::IsTriangle ( const Triangle & triangle)
constexpr

判断是否三角形

参数
[in]triangle三角形

在文件 dl_math.h887 行定义.

◆ IsXyInRect()

bool dl::Math::IsXyInRect ( const Point & xy,
const Rect & rect )
constexpr

判断 点是否在矩形内

参数
[in]rect矩形

在文件 dl_math.h876 行定义.

◆ IsXyInSize()

bool dl::Math::IsXyInSize ( const Point & xy,
const Size & size )
constexpr

判断 点是否在大小内

在文件 dl_math.h864 行定义.

◆ MergePath()

void dl::Math::MergePath ( std::list< Point > & list_pos)

路径合并(网格路径)

注解
方向相同且相邻的节点合并(最终路径不变)

◆ MergePathDirect()

template<typename F>
void dl::Math::MergePathDirect ( std::list< Point > & list_pos,
F func_pass )

路径合并(网格路径)

注解
两点之间没有障碍物,则删除之间的(路径会发生变化)

在文件 dl_math.h769 行定义.

◆ Normalize() [1/2]

template<IsSigned T, size_t N>
void dl::Math::Normalize ( Array< T, N > & v)

向量单位化

在文件 dl_math.h453 行定义.

◆ Normalize() [2/2]

template<IsSigned T, size_t N>
Array< T, N > dl::Math::Normalize ( const Array< T, N > & v)
nodiscard

在文件 dl_math.h463 行定义.

◆ NormalizeFast()

template<size_t N>
void dl::Math::NormalizeFast ( Array< float, N > & v)

向量单位化,精度低速度快

在文件 dl_math.h250 行定义.

◆ OffsetOrder()

float dl::Math::OffsetOrder ( float order,
int u = 1,
int v = 0,
int w = 0 )
constexpr

偏移order

参数
[in]order原本order
[in]u偏移大小,用户使用
[in]v偏移大小,多个组使用
[in]w偏移大小,单个元素内使用
注解
正数使order变大,更远离屏幕
如果偏移出 [0, 1]的范围,则限制到范围,并输出警告
在一组内,优先使用负数靠近屏幕

在文件 dl_math.h659 行定义.

◆ PI()

double dl::Math::PI ( unsigned n = 1,
unsigned d = 1 )
constexpr

返回PI的分数

参数
[in]n分子
[in]d分母

在文件 dl_math.h489 行定义.

◆ PIF()

float dl::Math::PIF ( unsigned n = 1,
unsigned d = 1 )
constexpr

在文件 dl_math.h497 行定义.

◆ Pow()

template<typename T>
T dl::Math::Pow ( T x,
T n )
constexpr

返回x的n次方

参数
[in]x底数,n64
[in]n指数,n8[0, 255]

在文件 dl_math.h131 行定义.

◆ Pow32()

uint32_t dl::Math::Pow32 ( uint32_t x,
uint8_t n )
constexpr

在文件 dl_math.h149 行定义.

◆ Pow64()

uint64_t dl::Math::Pow64 ( uint64_t x,
uint8_t n )
constexpr

在文件 dl_math.h140 行定义.

◆ Radian2Angle()

float dl::Math::Radian2Angle ( float radin)
constexpr

弧度转角度

在文件 dl_math.h84 行定义.

◆ RadiansToDegrees()

double dl::Math::RadiansToDegrees ( double rad)
constexpr

将弧度转为角度

在文件 dl_math.h1307 行定义.

◆ RangeRadian()

void dl::Math::RangeRadian ( std::array< float, 2 > & arr)
constexpr

在文件 dl_math.h100 行定义.

◆ RSqrt()

float dl::Math::RSqrt ( float x)
inline

返回平方根的倒数

注解
经测试,此方法并比1.0f / sqrt快那么一点
类型转换也需要时间,如果是非内联函数也会变慢许多。

在文件 dl_math.h230 行定义.

◆ Slerp()

Position4 dl::Math::Slerp ( const Position4 & q0,
const Position4 & q1,
const Float & t )

球面线性插值

注解
普通线性插值存在于std::lerp

◆ SubU() [1/4]

template<IsUnsigned T, size_t N>
Array< T, N > dl::Math::SubU ( const Array< T, N > & a,
const Array< T, N > & b )

无符号类型相减,负数转为0

在文件 dl_math.h344 行定义.

◆ SubU() [2/4]

template<IsUnsigned T0, IsSigned T1, size_t N>
Array< T0, N > dl::Math::SubU ( const Array< T0, N > & a,
const Array< T1, N > & b )

无符号减有符号,负数转为0

在文件 dl_math.h355 行定义.

◆ SubU() [3/4]

template<IsUnsigned T>
T dl::Math::SubU ( T a,
T b )

无符号类型相减,负数转为0

在文件 dl_math.h326 行定义.

◆ SubU() [4/4]

template<IsUnsigned T0, IsSigned T1>
T0 dl::Math::SubU ( T0 a,
T1 b )

无符号减有符号,结果负数转为0

在文件 dl_math.h334 行定义.

变量说明

◆ ARRAY_POW2

uint64_t dl::Math::ARRAY_POW2[]
constexpr
初始值:
= {
Pow64(2,0),Pow64(2,1),Pow64(2,2),Pow64(2,3),Pow64(2,4),Pow64(2,5),Pow64(2,6),Pow64(2,7),
Pow64(2,8),Pow64(2,9),Pow64(2,10),Pow64(2,11),Pow64(2,12),Pow64(2,13),Pow64(2,14),Pow64(2,15),
Pow64(2,16),Pow64(2,17),Pow64(2,18),Pow64(2,19),Pow64(2,20),Pow64(2,21),Pow64(2,22),Pow64(2,23),
Pow64(2,24),Pow64(2,25),Pow64(2,26),Pow64(2,27),Pow64(2,28),Pow64(2,29),Pow64(2,30),Pow64(2,31),
Pow64(2,32),Pow64(2,33),Pow64(2,34),Pow64(2,35),Pow64(2,36),Pow64(2,37),Pow64(2,38),Pow64(2,39),
Pow64(2,40),Pow64(2,41),Pow64(2,42),Pow64(2,43),Pow64(2,44),Pow64(2,45),Pow64(2,46),Pow64(2,47),
Pow64(2,48),Pow64(2,49),Pow64(2,50),Pow64(2,51),Pow64(2,52),Pow64(2,53),Pow64(2,54),Pow64(2,55),
Pow64(2,56),Pow64(2,57),Pow64(2,58),Pow64(2,59),Pow64(2,60),Pow64(2,61),Pow64(2,62),Pow64(2,63) }
constexpr uint64_t Pow64(uint64_t x, uint8_t n)

2的整数次幂列表

在文件 dl_math.h162 行定义.

◆ ARRAY_POW2_32

uint32_t dl::Math::ARRAY_POW2_32[]
constexpr
初始值:
= {
Pow32(2,0),Pow32(2,1),Pow32(2,2),Pow32(2,3),Pow32(2,4),Pow32(2,5),Pow32(2,6),Pow32(2,7),
Pow32(2,8),Pow32(2,9),Pow32(2,10),Pow32(2,11),Pow32(2,12),Pow32(2,13),Pow32(2,14),Pow32(2,15),
Pow32(2,16),Pow32(2,17),Pow32(2,18),Pow32(2,19),Pow32(2,20),Pow32(2,21),Pow32(2,22),Pow32(2,23),
Pow32(2,24),Pow32(2,25),Pow32(2,26),Pow32(2,27),Pow32(2,28),Pow32(2,29),Pow32(2,30),Pow32(2,31) }
constexpr uint32_t Pow32(uint32_t x, uint8_t n)

在文件 dl_math.h171 行定义.