Skip to content

Foundation Classes - Enhance MathRoot and MathSys with new utilities#954

Merged
dpasukhi merged 3 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:hot_fixes_math
Dec 25, 2025
Merged

Foundation Classes - Enhance MathRoot and MathSys with new utilities#954
dpasukhi merged 3 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:hot_fixes_math

Conversation

@dpasukhi
Copy link
Member

  • Added MathRoot_Trig_Test for comprehensive testing of trigonometric root finding.
  • Introduced MathSys_Newton2D for optimized 2D Newton-Raphson solver, including bounds checking and gradient descent fallback.
  • Updated FILES.cmake to include new test and utility files.
  • Added MathUtils_Domain for parameter domain management in curves and surfaces, enhancing domain analysis capabilities.

- Added MathRoot_Trig_Test for comprehensive testing of trigonometric root finding.
- Introduced MathSys_Newton2D for optimized 2D Newton-Raphson solver, including bounds checking and gradient descent fallback.
- Updated FILES.cmake to include new test and utility files.
- Added MathUtils_Domain for parameter domain management in curves and surfaces, enhancing domain analysis capabilities.
@dpasukhi dpasukhi requested a review from Copilot December 25, 2025 16:15
@dpasukhi dpasukhi self-assigned this Dec 25, 2025
@dpasukhi dpasukhi added 2. Bug Something isn't working 2. Enhancement New feature or request 1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code labels Dec 25, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Foundation Classes math libraries by introducing new utilities for root finding and domain management. The additions include comprehensive test coverage for trigonometric equation solving, an optimized 2D Newton-Raphson solver for common geometric problems, and lightweight domain management types for parameter bounds handling.

Key Changes:

  • Added comprehensive testing infrastructure for trigonometric root finding with multiple edge cases
  • Introduced optimized 2D Newton solver with gradient descent fallback and bounds checking
  • Created domain management utilities for 1D/2D parameter spaces
  • Fixed critical bugs in trigonometric root finding algorithm

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
MathUtils_Domain.hxx New lightweight domain types (Domain1D/Domain2D) for parameter space management
MathUtils/FILES.cmake Added MathUtils_Domain.hxx to build configuration
MathSys/README.md Documentation for new Newton2D solver capabilities and usage
MathSys_Newton2D.hxx Optimized 2D Newton-Raphson solver with Cramer's rule and symmetric Jacobian variant
MathSys/FILES.cmake Added MathSys_Newton2D.hxx to build configuration
MathRoot_Trig.hxx Fixed quadratic coefficient ordering and improved root refinement with Halley's method
MathRoot_Trig_Test.cxx Comprehensive test suite covering linear, quadratic, general cases, and edge cases
GTests/FILES.cmake Added MathRoot_Trig_Test.cxx to test build configuration

{
// c*cos(x) + d*sin(x) + e = 0
// Using t = tan(x/2): (e-c) + 2dt + (e+c)t^2 = 0
// Using t = tan(x/2): (e-c)*t^2 + 2d*t + (e+c) = 0
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment incorrectly describes the quadratic equation coefficients. The equation should be (e-c)t² + 2dt + (e+c) = 0, but the code correctly implements it as at² + bt + c where a=(e-c), b=2d, c=(e+c). The comment's notation '(e-c)*t^2' is misleading as it doesn't match the standard quadratic form ax² + bx + c = 0 that MathPoly::Quadratic expects.

Suggested change
// Using t = tan(x/2): (e-c)*t^2 + 2d*t + (e+c) = 0
// Using t = tan(x/2): (e - c)*t^2 + 2*d*t + (e + c) = 0,
// i.e. a quadratic a*t^2 + b*t + c = 0 with a = (e - c), b = 2*d, c = (e + c).

Copilot uses AI. Check for mistakes.
Comment on lines +380 to +381
constexpr int THE_MAX_ITER = 20;
constexpr double THE_TOL = 1.0e-14;
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constants THE_MAX_ITER and THE_TOL use global-style naming (all caps with THE_ prefix) but are local constexpr variables within a lambda. According to OCCT conventions, local variables should use aVariableName style. These should be renamed to aMaxIter and aTol respectively.

Copilot uses AI. Check for mistakes.
Comment on lines +422 to +425
constexpr double THE_MAX_STEP = 0.5;
if (std::abs(aDelta) > THE_MAX_STEP)
{
aDelta = (aDelta > 0) ? THE_MAX_STEP : -THE_MAX_STEP;
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant THE_MAX_STEP uses global-style naming but is a local constexpr variable. According to OCCT conventions, it should be renamed to aMaxStep to follow local variable naming patterns.

Suggested change
constexpr double THE_MAX_STEP = 0.5;
if (std::abs(aDelta) > THE_MAX_STEP)
{
aDelta = (aDelta > 0) ? THE_MAX_STEP : -THE_MAX_STEP;
constexpr double aMaxStep = 0.5;
if (std::abs(aDelta) > aMaxStep)
{
aDelta = (aDelta > 0) ? aMaxStep : -aMaxStep;

Copilot uses AI. Check for mistakes.
…t notation for cosine values (± to +/-) and update mathematical expressions for clarity (cos² to cos^2).
@dpasukhi dpasukhi merged commit e7d1148 into Open-Cascade-SAS:IR Dec 25, 2025
24 checks passed
@dpasukhi dpasukhi deleted the hot_fixes_math branch December 25, 2025 21:22
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 2. Bug Something isn't working 2. Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants