#ifndef PST_COMMONFUNCTION_H #define PST_COMMONFUNCTION_H //#include "PostProcessingModuleConfig.h" #include #include namespace pst { class CommonFunction { public: CommonFunction(); public: // 字符串分割 static void Stringsplit(const std::string& str, const std::string& splits, std::vector& res); //去除字符串首尾空格 static std::string trim(const std::string& s); //球坐标(角度制)转直角坐标-->点 static void SphereToRectangularCoorSys(const double theta, const double phi, const double r, double& x, double& y, double& z); static void PolarToRectangularCoorSys(const double theta, const double r, double& x, double& y); //判断两个浮点数是否相等 // ulp: units in the last place. template typename std::enable_if::is_integer, bool>::type IsAlmostEqual(T x, T y, int ulp = 2) { // the machine epsilon has to be scaled to the magnitude of the values used // and multiplied by the desired precision in ULPs (units in the last place) return std::fabs(x - y) < std::numeric_limits::epsilon() * std::fabs(x + y) * ulp // unless the result is subnormal || std::fabs(x - y) < std::numeric_limits::min(); } }; } #endif // QVTK_COMMONFUNCTION_H