The MathSys package provides algorithms for solving systems of nonlinear equations. These solvers are used by geometric algorithms for extrema, projection, and intersection tasks.
MathSys_Newton.hxx)The generic Newton-Raphson method solves systems F(X) = 0 by repeatedly solving J(X) * dX = -F(X).
Features:
MathSys_Newton2D.hxx)Specialized 2D solvers target compact, allocation-free execution for common CAD kernels.
Features:
math_Vector/math_Matrix in iteration loop)sqrt)Functions:
MathSys::Solve2D() - General 2D Newton solverMathSys::Solve2DSymmetric() - Robust 2D solver for symmetric Jacobian systemsUsage Example (2D):
#include <MathSys_Newton2D.hxx> MySymmetricFunc aFunc; MathSys::NewtonBoundsN<2> aBounds; aBounds.Min = {-10.0, -10.0}; aBounds.Max = {10.0, 10.0}; MathSys::NewtonOptions aOptions; aOptions.FTolerance = 1.0e-10; aOptions.MaxIterations = 100; aOptions.EnableLineSearch = true; const MathSys::NewtonResultN<2> aResult = MathSys::Solve2DSymmetric(aFunc, {0.0, 0.0}, aBounds, aOptions); if (aResult.IsDone()) { const double aU = aResult.X[0]; const double aV = aResult.X[1]; }
MathSys_Newton3D.hxx)3D solvers cover constrained geometric systems such as curve-surface extrema.
Features:
Functions:
MathSys::Solve3D() - General 3D Newton solverMathSys::SolveCurveSurfaceExtrema3D() - Specialized curve-surface extrema solverUsage Example (General 3D):
#include <MathSys_Newton3D.hxx> MyFunc3D aFunc; MathSys::NewtonBoundsN<3> aBounds; aBounds.Min = {-100.0, -100.0, -100.0}; aBounds.Max = {100.0, 100.0, 100.0}; MathSys::NewtonOptions aOptions; aOptions.FTolerance = 1.0e-10; aOptions.MaxIterations = 100; const MathSys::NewtonResultN<3> aResult = MathSys::Solve3D(aFunc, {1.0, 2.0, 3.0}, aBounds, aOptions); if (aResult.IsDone()) { const double aX1 = aResult.X[0]; const double aX2 = aResult.X[1]; const double aX3 = aResult.X[2]; }
Usage Example (Curve-Surface Extrema):
#include <MathSys_Newton3D.hxx> CurveEval aCurve; SurfaceEval aSurface; MathSys::NewtonBoundsN<3> aBounds; aBounds.Min = {tMin, uMin, vMin}; aBounds.Max = {tMax, uMax, vMax}; MathSys::NewtonOptions aOptions; aOptions.FTolerance = tolerance; aOptions.MaxIterations = maxIter; const MathSys::NewtonResultN<3> aResult = MathSys::SolveCurveSurfaceExtrema3D(aCurve, aSurface, {t0, u0, v0}, aBounds, aOptions);
MathSys_Newton4D.hxx)4D solvers handle coupled geometric systems such as surface-surface extrema.
Features:
Functions:
MathSys::Solve4D() - General 4D Newton solverMathSys::SolveSurfaceSurfaceExtrema4D() - Specialized surface-surface extrema solverUsage Example (General 4D):
#include <MathSys_Newton4D.hxx> MyFunc4D aFunc; MathSys::NewtonBoundsN<4> aBounds; aBounds.Min = {-10.0, -10.0, -10.0, -10.0}; aBounds.Max = {10.0, 10.0, 10.0, 10.0}; MathSys::NewtonOptions aOptions; aOptions.FTolerance = 1.0e-10; aOptions.MaxIterations = 100; const MathSys::NewtonResultN<4> aResult = MathSys::Solve4D(aFunc, {0.0, 0.0, 0.0, 0.0}, aBounds, aOptions);
Usage Example (Surface-Surface Extrema):
#include <MathSys_Newton4D.hxx> SurfaceEval1 aSurf1; SurfaceEval2 aSurf2; MathSys::NewtonBoundsN<4> aBounds; aBounds.Min = {u1Min, v1Min, u2Min, v2Min}; aBounds.Max = {u1Max, v1Max, u2Max, v2Max}; MathSys::NewtonOptions aOptions; aOptions.FTolerance = tolerance; aOptions.MaxIterations = maxIter; const MathSys::NewtonResultN<4> aResult = MathSys::SolveSurfaceSurfaceExtrema4D(aSurf1, aSurf2, {u1_0, v1_0, u2_0, v2_0}, aBounds, aOptions);
MathSys_LevenbergMarquardt.hxx)Levenberg-Marquardt targets nonlinear least-squares problems by minimizing ||F(X)||^2. It blends Gauss-Newton speed near minima with gradient-descent robustness far from minima.
Features:
MathSys exposes two interface styles:
Generic vector API:
MathSys_Newton.hxx, MathSys_LevenbergMarquardt.hxxmath_Vector/math_Matrix-based interfacesMathUtils::VectorResultSpecialized small-dimension API:
MathSys_Newton2D.hxx, MathSys_Newton3D.hxx, MathSys_Newton4D.hxxMathSys::NewtonResultN<N>Shared specialized API types are defined in MathSys_NewtonTypes.hxx:
MathUtils::StatusMathSys::NewtonResultN<N>MathSys::NewtonBoundsN<N>MathSys::NewtonOptionsResidualNorm <= FTolerance).Status::OK status.Solve2DSymmetric() uses Armijo backtracking with directional derivative based on J^T * F.MathUtils - common utilities, numeric types, and generic solver supportgp package - geometric point/vector primitives for extrema-specialized solvers