Repository: opencv/opencv
File: samples/cpp/gauge.cpp (C++)

Code before:
    vector<Vec3f> circles;
    HoughCircles(gray, circles, HOUGH_GRADIENT, 1,
                 20,
                 100, 50,
                 static_cast<int>(height * 0.35),
                 static_cast<int>(height * 0.48));

    if (circles.empty()) {
        cerr << "No circles found." << endl;
        exit(1);
    }

    Vec3f avg = avg_circles(circles);
    int x = static_cast<int>(avg[0]);
    int y = static_cast<int>(avg[1]);
    int r = static_cast<int>(avg[2]);

    cal.x = x;
    cal.y = y;
    cal.r = r;

    // Draw the circle and the center.
    circle(img, Point(x, y), r, Scalar(0, 0, 255), 3, LINE_AA);
    circle(img, Point(x, y), 2, Scalar(0, 255, 0), 3, LINE_AA);

    // Gneration of calibration lines
    double separation = 10.0; // em graus
    int interval = static_cast<int>(360.0 / separation);

    vector<Point2f> p1(interval);
    vector<Point2f> p2(interval);
    vector<Point2f> p_text(interval);

    for (int i = 0; i < interval; ++i) {
        double angle_rad = separation * i * CV_PI / 180.0;
        p1[i].x = x + 0.9 * r * std::cos(angle_rad);
        p1[i].y = y + 0.9 * r * std::sin(angle_rad);
    }

    int text_offset_x = 10;
    int text_offset_y = 5;

    for (int i = 0; i < interval; ++i) {
        double angle_rad = separation * i * CV_PI / 180.0;
        p2[i].x = x + r * std::cos(angle_rad);
        p2[i].y = y + r * std::sin(angle_rad);

        double text_angle_rad = separation * (i + 9) * CV_PI / 180.0; // i+9 = rotaciona 90°
        p_text[i].x = x - text_offset_x + 1.2 * r * std::cos(text_angle_rad);
        p_text[i].y = y + text_offset_y + 1.2 * r * std::sin(text_angle_rad);
    }

Review comment (suggestion):
```suggestion
    // Generation of calibration lines
```

Code after:
    vector<Vec3f> circles;
    HoughCircles(gray, circles, HOUGH_GRADIENT, 1,
                 20,
                 100, 50,
                 static_cast<int>(height * 0.35),
                 static_cast<int>(height * 0.48));

    if (circles.empty()) {
        cerr << "No circles found." << endl;
        exit(1);
    }

    Vec3f avg = avg_circles(circles);
    int x = static_cast<int>(avg[0]);
    int y = static_cast<int>(avg[1]);
    int r = static_cast<int>(avg[2]);

    cal.x = x;
    cal.y = y;
    cal.r = r;

    // Draw the circle and the center.
    circle(img, Point(x, y), r, Scalar(0, 0, 255), 3, LINE_AA);
    circle(img, Point(x, y), 2, Scalar(0, 255, 0), 3, LINE_AA);

    // Generation of calibration lines.
    double separation = 10.0; // in degrees
    int interval = static_cast<int>(360.0 / separation);

    vector<Point2d> p1(interval);
    vector<Point2d> p2(interval);
    vector<Point2d> p_text(interval);

    for (int i = 0; i < interval; ++i) {
        double angle_rad = separation * i * CV_PI / 180.0;
        p1[i].x = x + 0.9 * r * std::cos(angle_rad);
        p1[i].y = y + 0.9 * r * std::sin(angle_rad);
    }

    int text_offset_x = 10;
    int text_offset_y = 5;

    for (int i = 0; i < interval; ++i) {
        double angle_rad = separation * i * CV_PI / 180.0;
        p2[i].x = x + r * std::cos(angle_rad);
        p2[i].y = y + r * std::sin(angle_rad);

        double text_angle_rad = separation * (i + 9) * CV_PI / 180.0; // i+9 = rotate 90°
        p_text[i].x = x - text_offset_x + 1.2 * r * std::cos(text_angle_rad);
        p_text[i].y = y + text_offset_y + 1.2 * r * std::sin(text_angle_rad);
    }