Fix issue that Geometry::deg2rad() do calculation in the same type as the parameter, which means if the parameter is int then you lose all the precision

This commit is contained in:
Noisyfox
2026-05-07 22:24:45 +08:00
parent 8b716d43e5
commit 83e9f17aa8
2 changed files with 6 additions and 2 deletions

View File

@@ -298,7 +298,11 @@ bool directions_perpendicular(double angle1, double angle2, double max_diff = 0)
template<class T> bool contains(const std::vector<T> &vector, const Point &point);
template<typename T> T rad2deg(T angle) { return T(180.0) * angle / T(PI); }
double rad2deg_dir(double angle);
template<typename T> constexpr T deg2rad(const T angle) { return T(PI) * angle / T(180.0); }
template<typename T> constexpr T deg2rad(const T angle)
{
static_assert(std::is_floating_point<T>::value, "Why do you want to calculate angle in integer?");
return T(PI) * angle / T(180.0);
}
template<typename T> T angle_to_0_2PI(T angle)
{
static const T TWO_PI = T(2) * T(PI);

View File

@@ -2399,7 +2399,7 @@ private:
return line.distance(p);
}
};
const double TriangleCursor::facet_angle_limit = cos(Geometry::deg2rad(5));
const double TriangleCursor::facet_angle_limit = cos(Geometry::deg2rad(5.0));
// Remap painting data from source mesh to target mesh using spatial mapping.