Repository: FreeCAD/FreeCAD
File: src/Mod/Sketcher/App/SketchObject.cpp (C++)

Code before:
        if (construction && !geoNew->is<Part::GeomPoint>()) {
            GeometryFacade::setConstruction(geoNew, true);
        }
        newVals.push_back(geoNew);
    }

    auto applyConstraintFlipCorrection = [xinv, yinv]
                                         (Sketcher::Constraint* newConstr) {
        if (!(xinv || yinv)) {
            return;
        }

        // DistanceX, DistanceY
        if ((xinv && newConstr->Type == Sketcher::DistanceX) ||
            (yinv && newConstr->Type == Sketcher::DistanceY)) {
            if (newConstr->First == newConstr->Second) {
                std::swap(newConstr->FirstPos, newConstr->SecondPos);
            } else{
                newConstr->setValue(-newConstr->getValue());
            }
        }

        // Angle
        if (newConstr->Type == Sketcher::Angle) {
            auto normalizeAngle = [](double angleDeg) {
                while (angleDeg > M_PI) angleDeg -= M_PI * 2.0;
                while (angleDeg <= -M_PI) angleDeg += M_PI * 2.0;
                return angleDeg;
            };

            if (xinv && yinv) { // rotation 180 degrees around normal axis
                if (newConstr->First ==-1 || newConstr->Second == -1
                    || newConstr->First == -2 || newConstr->Second == -2
                    || newConstr->Second == GeoEnum::GeoUndef) {
                    // angle to horizontal or vertical axis
                    newConstr->setValue(normalizeAngle(newConstr->getValue() + M_PI));
                }
                else {
                    // angle between two sketch entities
                    // do nothing
                }
            }
            else if (xinv) { // rotation 180 degrees around vertical axis
                if (newConstr->First == -1 || newConstr->Second == -1 || newConstr->Second == GeoEnum::GeoUndef) {
                    // angle to horizontal axis
                    newConstr->setValue(normalizeAngle(M_PI - newConstr->getValue()));
                }
                else {
                    // angle between two sketch entities or angle to vertical axis
                    newConstr->setValue(normalizeAngle(-newConstr->getValue()));
                }

Review comment (suggestion):
Can you replace these uses of `M_PI` with `std::numbers::pi`? We normally do it with a `using std::numbers::pi` at the top of the method.

Code after:
        }
        generateId(geoNew);
        if (construction && !geoNew->is<Part::GeomPoint>()) {
            GeometryFacade::setConstruction(geoNew, true);
        }
        newVals.push_back(geoNew);
    }

    auto applyConstraintFlipCorrection = [xinv, yinv]
                                         (Sketcher::Constraint* newConstr) {
        if (!xinv && !yinv) {
            return;
        }

        // DistanceX, DistanceY
        if ((xinv && newConstr->Type == Sketcher::DistanceX) ||
            (yinv && newConstr->Type == Sketcher::DistanceY)) {
            if (newConstr->First == newConstr->Second) {
                std::swap(newConstr->FirstPos, newConstr->SecondPos);
            } else{
                newConstr->setValue(-newConstr->getValue());
            }
        }

        // Angle
        if (newConstr->Type == Sketcher::Angle) {
            auto normalizeAngle = [](double angleDeg) {
                while (angleDeg > pi) angleDeg -= pi * 2.0;
                while (angleDeg <= -pi) angleDeg += pi * 2.0;
                return angleDeg;
            };

            if (xinv && yinv) { // rotation 180 degrees around normal axis
                if (newConstr->First ==-1 || newConstr->Second == -1
                    || newConstr->First == -2 || newConstr->Second == -2
                    || newConstr->Second == GeoEnum::GeoUndef) {
                    // angle to horizontal or vertical axis
                    newConstr->setValue(normalizeAngle(newConstr->getValue() + pi));
                }
                else {
                    // angle between two sketch entities
                    // do nothing
                }
            }
            else if (xinv) { // rotation 180 degrees around vertical axis
                if (newConstr->First == -1 || newConstr->Second == -1 || newConstr->Second == GeoEnum::GeoUndef) {
                    // angle to horizontal axis
                    newConstr->setValue(normalizeAngle(pi - newConstr->getValue()));
                }
                else {
                    // angle between two sketch entities or angle to vertical axis