26 static constexpr T
Pi() {
27 static_assert(std::is_floating_point<T>::value,
"type must be floating point");
28 return static_cast<T
>(3.14159265358979323846264338327950288);
33 static constexpr T
Pi2() {
34 static_assert(std::is_floating_point<T>::value,
"type must be floating point");
35 return static_cast<T
>(
static_cast<T
>(2) * Pi<T>());
41 static_assert(std::is_floating_point<T>::value,
"type must be floating point");
42 return rad * (T(180.0) / Pi<T>());
48 static_assert(std::is_floating_point<T>::value,
"type must be floating point");
49 return deg * (Pi<T>() / T(180.0));
54 static T
Clamp(T a, T
min = T(0), T max = T(1)) {
55 return std::min(std::max(a,
min), max);
71 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
76 return a.
x * b.
x + a.
y * b.
y;
101 return a * (1.0f - f) + (b * f);
double min(double v1, double v2)
返回两个数中的较小值
static auto Cross(const Vector3D &a, const Vector3D &b)
static auto DistanceSquared2D(const Vector3D &a, const Vector3D &b)
static Vector3D GetRightVector(const Rotation &rotation)
计算指向 rotation 的 Y 轴的单位向量
static constexpr T ToRadians(T deg)
static float LinearLerp(float a, float b, float f)
static double GetVectorAngle(const Vector3D &a, const Vector3D &b)
返回两个向量之间的夹角(弧度)
static Vector3D GetUpVector(const Rotation &rotation)
计算指向 rotation 的 Z 轴的单位向量
static auto Distance2D(const Vector3D &a, const Vector3D &b)
static std::vector< int > GenerateRange(int a, int b)
static Vector3D RotatePointOnOrigin2D(Vector3D p, float angle)
static auto DistanceSquared(const Vector3D &a, const Vector3D &b)
static T Clamp(T a, T min=T(0), T max=T(1))
static auto Dot(const Vector3D &a, const Vector3D &b)
static Vector3D GetForwardVector(const Rotation &rotation)
计算指向 rotation 的 X 轴的单位向量
static std::pair< float, float > DistanceSegmentToPoint(const Vector3D &p, const Vector3D &v, const Vector3D &w)
计算点到线段的距离 返回一个包含:
static T Square(const T &a)
static auto Distance(const Vector3D &a, const Vector3D &b)
static constexpr T ToDegrees(T rad)
static auto Dot2D(const Vector3D &a, const Vector3D &b)
static std::pair< float, float > DistanceArcToPoint(Vector3D p, Vector3D start_pos, float length, float heading, float curvature)
计算点到弧的距离 返回一个包含: