diff --git a/src/林火预测/pixel.h b/src/林火预测/pixel.h index 5a590a6..0906e4f 100644 --- a/src/林火预测/pixel.h +++ b/src/林火预测/pixel.h @@ -1,3 +1,5 @@ +#include + class PixelRatioConverter { public: // 캯ʵеͼռ @@ -9,21 +11,36 @@ public: } // ȡرϵ - double getPixelRatio() { - double ratio = (real_area1 / real_area2) * (pixel_area2 / pixel_area1); + double getPixelRatio() const { + double ratio = calculateAreaRatio() * calculatePixelRatio(); return ratio; // رϵ } // رϵһͼռ - int getNextPixelArea(int next_real_area) { + int getNextPixelArea(int next_real_area) const { double ratio = this->getPixelRatio(); - int next_pixel_area = static_cast(next_real_area / ratio); + int next_pixel_area = calculateNextPixelArea(next_real_area, ratio); return next_pixel_area; // һͼռ } private: - double real_area1; // һʵе - double real_area2; // ڶʵе - int pixel_area1; // һͼռ - int pixel_area2; // ڶͼռ + double real_area1; // һʵе + double real_area2; // ڶʵе + int pixel_area1; // һͼռ + int pixel_area2; // ڶͼռ + + // ʵ֮ıϵ + double calculateAreaRatio() const { + return real_area1 / real_area2; + } + + // ֮ıϵ + double calculatePixelRatio() const { + return static_cast(pixel_area2) / pixel_area1; + } + + // ݱϵһʵͼռ + int calculateNextPixelArea(int next_real_area, double ratio) const { + return static_cast(next_real_area / ratio); + } };