725 Commits
Author SHA1 Message Date
David Eberly d29e7758ae Update ContPointInPolyhedron3.h
Defect reported by Claude Sonnet5/Fable5. The std::vector member
mProjVertices occurs in a loop over all faces. It stores the projections
onto a plane which are later processed. The member is resized each time the current faceIndices has a larger number of elements that mProjVertices. There is no clear call, so if the number of current faceIndices is smaller than that of mProjVertices, the ensuing code accesses elements of mProjVertices that were set for the previous triangles. I removed the mProjVertices member and now have local storage for the projection vertices that is created for each incoming face. While I was in there, I refactored the code in an attempt to simply
the class interface. There is only one face data structure used for triangles, convex polygons, and simple polygons. Consequently, the class has a single constructor to which you pass a parameter specifying the type of face to be processed. I factored out shared code for ContainsC1C2 and ContainsS1 into SharedContains.
2026-08-13 21:46:47 -07:00
David Eberly 3e43b79905 Modified project for deprecation of source code.
Removed ApprConvexQuadByRect.h.
2026-08-12 08:27:29 -07:00
David Eberly 03126b7b52 Delete ApprConvexQuadByRect.h
Claude Sonnet 5 reported a defect in  ApprConvexQuadByRect.h. It
appeared to be a false positive. However, I analyzed the code and re-read the PDF for the fitting algorithm (Fit a Convex Quadrilateral by a Rectangle). The second equality in equation (5) of the PDF is horribly wrong. Moreover, the PDF is nearly impossible to read and understand. I removed the header file from the GTE source code and I removed the PDF from the documentation database. The motivation for the algorithm was based on user request, to approximate a nearly
rectangular quadrilateral by a rectangle. It is simpler to use the
minimum-area bounding rectangle code (\Code{MininumAreaBox2.h}).
2026-08-12 08:21:44 -07:00
David Eberly 8275bbb490 Update RootsPolynomial.h
Defect reported by Claude Sonnet5/Fable5. In the Find function that
uses bisection, if the loop involving maxIterations is encountered and
maxIterations is zero, root is unassigned and the return value is true. The caller believes a root is found but accesses uninitialized memory. I added a trap for maxIterations being zero before the loop is reached; if zero, the function exits. In all the conditions where there is no
root computed, root is assigned zero to avoid uninitialized memory.
2026-08-11 14:11:44 -07:00
David Eberly ac8277a9f8 Update SurfaceExtractorTetrahedra.h
Defect reported by Claude Sonnet5/Fable5. The AddTriangle function
tests whether a triangle is in a set. If it is not, the function has nothing
to do and exits. If it is, a test is applied to see whether the to-be-inserted triangle has a duplicate in the set; this triangle has opposite winding order, so the function swaps the last two vertices of the input triangle. If there is no duplicate, the triangle is added to the set. However, the last two vertices had been swapped. They need to be swapped back to the original order of the input triangle.
2026-08-11 13:51:42 -07:00
David Eberly 3f30cf6d72 Update MinimumSpanningTree.h
Defect reported by Claude Sonnet5/Fable5. There is no defect. The minimum spanning tree data structure contains a sentinel followed by the tree. The sentinel is {nil,vertexIndex}, where vertexIndex is the
index into the vertex array corresponding to the first vertex visited by
the tree construction. I added comments about this in hopes later Claude runs will not flag this as a defect.
2026-08-11 10:44:32 -07:00
David Eberly db8560d62c Update RotationEstimate.h
Defect found by Claude Sonnet5/Fable5. The degree-16 constants in
C_ROTC4_EST_COEFF} have an entry +2.505210838484547384e-08 which is missing a terminating constant. The compiler adds the next constant to it, in which case the last constant of the array is implicitly zero. I added the comma.
2026-08-10 16:20:43 -07:00
David Eberly 980e680e76 Update Hyperellipsoid.h
Defect found by Claude Sonnet5/Fable5. This is actually a warning about potential numerical issues in ToCoefficients, the variation accepting an array of numbers. The warning was about skipping a loop index when trying to determine a number to divide all the coefficients to transform them to a range containing floating-point 1. I redesigned this to divide by the maximum-magnitude coefficient of the quadratic terms. I also removed some comments about Microsoft Visual Studio 2019 code analysis generating incorrect warnings.
2026-08-10 15:59:30 -07:00
David Eberly d55b847edc Update NURBSSphere.h
Defect found by Claude Sonnet5/Fable5. In the second derivative computations of NURBSEighthSphereDegree4, the tempDuu, tempDuv, and tempDvv equations had a leading multiplication by D. This is incorrect, so the leading D multiplications were removed. I found a second bug that Claude did not detect. In the first derivative computations, Bu[1][3] was computed as (Real)4 * vv. This should be
(Real)4 * v * vv. After fixing the bugs, I implemented the NURBS code
using Mathematica 15.0.1.0 and verified that the GTE/GTL C++ code produces correct results.
2026-08-10 12:05:17 -07:00
David Eberly 89f024c114 Update NURBSCircle.h
Defect found by Claude Sonnet5/Fable5. When I added the class
NURBSCircularArcDegree2, I introduced a regression in the class
NURBSQuarterCircleDegree2. For some unknown reason, the control points of NURBSQuarterCircleDegree2 were modified from {(1,0), (1,1), (0,1)} to {(1,1),(1,1),(1,1)}. Probably a copy-and-forgot-to-modify error.
2026-08-09 12:40:01 -07:00
David Eberly 79054919bc Fixed return value of approximator.
Defect found by Claude Sonnet5/Fable5. FitUsingSquaredLengths has a loop that terminates if the number of iterations exceeds maxIterations specified by the caller. The old return value is ++iteration, which is maxIterations+1 on non-convergence. I now return iteration.
2026-08-09 11:47:06 -07:00
David Eberly 11621154ff Update BVTree.h
I had fixed a bug in the bounding volume tree code for GTE; see the August 1, 2026 update notes. Unfortunately, I had not fixed the bug in the GTL code. A regression was introduced when I backported the GTL code to GTE. I fixed this.
2026-08-09 10:45:04 -07:00
David Eberly 1064fe61b4 Updated mathematics project files.
Added the new files and removed old files for the bounding volume tree code that was backported from GTL to GTE.
2026-08-08 16:58:51 -07:00
David Eberly 50d261ed0f Backported bounding volume tree code from GTL to GTE.
I backported the bounding volume tree code from GTL to GTE. GTE now supports trees for points, segments, or triangles. Part of the backport involved refactoring the classes to share more code, making the derived tree classes simpler to write. The file ApprCone3EllipseAndPoints.h was modified to support the new oriented box tree code. In the process of testing with the sample application, I encountered an exception: press key `3' followed by `b'.
An array of shared pointers of meshes is created in  CreateScene with a reserve call followed by multiple push_back calls. However, CreateScene is called multiple times (pressing keys to change the
test mesh). The array winds up having several null pointers, which causes the graphics engine Draw call to throw an exception. The fix was to add a clear call after the reserve call.
2026-08-08 16:50:15 -07:00
David Eberly f538a76e8d Update ReparameterizeByArclength.h
Defect found by Claude Sonnet5/Fable5. The function BisectionConverged compared fMin <= fMax. It needs to compare std::fabs(fMin) <= std::fabs(fMax); otherwise, the result is the same endpoint regardless of which is actually closer to the root. This can lead to a 1 ULP error in nearest floating-point number.
2026-08-08 13:05:48 -07:00
David Eberly c0b9db0234 Update DistPoint3Cylinder3.h
The file uses LogAssert. For some reason previous compiles allowed
access to this even though there is no include of Logger.h. Now the
compiler does complain (perhaps a difference in MSVS 2022 and MSVS 2026). I added the include.
2026-08-08 09:43:09 -07:00
David Eberly adee6124f9 Removed std::isfinite calls.
Removed the std::isfinite calls to allow compilation using GTE's
rational arithmetic classes. The GTL code already has these removed.
2026-08-08 09:25:51 -07:00
David Eberly f82380ae19 Update HermiteQuintic.h
Defect found by Claude Sonnet5/Fable5. The function P2D5 called P3D4 but should call P3D5. Modified the code and verified the
correctness using Mathematica.
2026-08-07 22:34:29 -07:00
David Eberly 419224b114 Fixed compile breaks.
My instantiation test failed to run. Got it running and fixed the compile breaks.
2026-08-07 15:35:57 -07:00
David Eberly 02a7f4807b Update AdaptiveSkeletonClimbing3.h
Defect found by Claude Sonnet5/Fable5. In GetGradient, the gradient[2] term uses (oneMinusY,OneMinusY) for the weights. These should be (oneMinusY,fy).
2026-08-07 15:19:58 -07:00
David Eberly aae5c85bf8 Revised the image utility header files.
Defect found by Claude Sonnet5/Fable5. Function ImageUtility3::Dilate has a design different from that of  ImageUtility2::Dilate. The 3D version failed to set boundary voxels to 1 when a neighboring voxel is 1. I rewrote ImageUtility3::Dilate to match the design of the 2D version. While I was in there, I added the 3D morphology functions for Erode, Open, and Close. I also moved the 2D and 3D component labelers to public scope because they might be useful in some applications. Finally, I reformatted both the 2D and 3D files to match the interface designs.
2026-08-07 15:07:42 -07:00
David Eberly 54c03f78d0 Update Cone.h
Defect found by Claude Sonnet5/Fable5. In the CreateMesh function, the line of code for tNumExtra has a division by rMin. For a finite cone with hMin of zero, there is a division by zero which leads to tNumExtra of positive infinity. I modified rMax/rMin to (1+rMax)/(1+rMin) to avoid the division by zero. I also added a TODO about determining how I derived the tNumExtra equation.
2026-08-06 22:11:15 -07:00
David Eberly 2456ff19e1 Fixed crash bug in Execute functions.
Defect found by Claude Sonnet5/Fable5. The Execute functions of
BVTreeOfTriangles and OBBTreeOfTriangles create
std::vector<size_t> indexStack(2 * this->mHeight)}. If the input tree has height of zero, the index stack is empty, so the code indexStack[0] = 0 crashes. The number of index stack elements must be 2 * this->mHeight + 1.
2026-08-01 11:36:55 -07:00
David Eberly 8e3baa93dc Update StringUtility.h
Defect found by Claude Sonnet5/Fable5. The GetTextTokens function has a loop with upper bound i < 255. This should be i <= 255.
2026-08-01 11:00:46 -07:00
David Eberly 93b8acda69 Update Constants.h
Defect found by Claude Sonnet5/Fable5. The following constants differ from the correctly rounded IEEE floating-point numbers: GTE_C_INV_TWO_PI differs by 2 ULP, GTE_C_INV_HALF_PI} differs by 1 ULP, and GTE_C_DEG_TO_RAD differs by 1 ULP. I computed the correctly rounded numbers using rational arithmetic and Machin's formula [pi = 16 atan(1/5) - 4 atan(1/239)]. The power series terms were partially summed until the rounded double-precision values between two consecutive partial sums were equal.
2026-08-01 10:54:43 -07:00
David Eberly 3f72a78d15 Fixed division by zero for degenerate line segments.
Defect found by Claude Sonnet5/Fable5. The find-intersection query has a division by segExtent. If the segment is degenerate, representing a single point (p[0] and p[1] are the same point), the segment extent is zero whereby the query has a division by zero. Additionally, the parameter value is zero, so result.parameter[i] / segExtent is
indeterminate (0/0). I added a guard against this case which calls a point-in-box query when the segment is degenerate. Claude's analysis did not report a second problem. The DoQuery method does not fill in the result members for index 1. When the projection intervals touch in a single point (numIntersections is 1), I increment this to 2 in case the caller references those values (undefined behavior without this).
The same division-by-zero problem occurs in the segment-oriented-box code. I also added a guard against this case.
2026-07-31 17:36:57 -07:00
David Eberly 43a484e503 Update DistPoint3Cylinder3.h
Defect found by Claude Sonnet5/Fable5. DoQueryInfiniteCylinder has a division by distance, which leads to an indeterminate form when
cylinder.radius is zero. Exception handling was added to throw when
the radius is not positive. Also, DoQueryFiniteCylinder now throws an exception when the height is not positive.
2026-07-30 21:41:18 -07:00
David Eberly bb27d5e54c Update IntrTetrahedron3Tetrahedron3.h
Defect found by Claude Sonnet5/Fable5. The edge-edge double loop had P1=tetra0.v[edge1Indices[0]]. The wrong tetrahedron is accessed. It
should be tetra1.
2026-07-30 16:07:11 -07:00
David Eberly e00988def9 Update SingularValueDecomposition.h
Defect found by Claude Sonnet5/Fable5. ComputeVOrthogonal has a loop with upper bound mNumCols-3. This works for matrices with 3 or more columns, but it fails when the number of columns is 2. The `col' index wraps to SIZE_MAX and the result is a crash when trying to reference an empty matrix. I added code to execute the loop only when mNumCols is 3 or larger.
2026-07-30 14:56:32 -07:00
David Eberly 636c156c02 Update BSNumber.h
I thought the negations of unsigned integers in the constructors with input 'number' were fixed. Running my instantiation tests showed that there is still a bug. The negative has to occur before the static cast, not after.
2026-06-08 12:08:16 -07:00
David Eberly e095b84018 Changes to CMakeLists.txt files.
Changes to CMakeLists.txt files. Based on CMake warnings, increased the minimum required cmake version to 3.10 from 3.8. Modified the GTE_MINOR_VERSION to 2.
GTE-version-8.2
2026-03-14 11:06:37 -07:00
David Eberly 36dd7961a9 Tests not included in GTE.
These appear to be part of the Claude Code analysis for bugs and defects.
2026-02-27 16:33:21 -08:00
David Eberly 389f187f8c Merge pull request #137 from CodeReclaimers/fix/natural-spline-2point-segfault
Require numPoints >= 3 for NaturalCubicSpline and NaturalQuinticSpline
2026-02-27 16:16:48 -08:00
David Eberly 0f2a8eef82 Merge branch 'master' into fix/natural-spline-2point-segfault 2026-02-27 16:16:40 -08:00
David Eberly c10318c4a7 Merge pull request #167 from CodeReclaimers/fix/trivial-comment-typo-fixes
Fix trivial typos in MathematicsGPU shader/header files
2026-02-27 16:14:40 -08:00
David Eberly 684c943f49 Merge pull request #166 from CodeReclaimers/fix/primal-query3-precision-table
Fix precision table typo in PrimalQuery3.h
2026-02-27 16:14:02 -08:00
David Eberly 2b23ac74e9 Merge pull request #165 from CodeReclaimers/fix/arc2-default-constructor
Fix Arc2 default constructor endpoints
2026-02-27 16:13:30 -08:00
David Eberly 11337ddc70 Merge pull request #164 from CodeReclaimers/fix/intr-line2-circle2-documentation
Add unit-length direction documentation to IntrLine2Circle2.h
2026-02-27 16:12:16 -08:00
David Eberly 33d306c35b Merge pull request #163 from CodeReclaimers/fix/dist-line2-triangle2-bugs
Fix NoCommonPoints bugs in DistLine2Triangle2.h
2026-02-27 16:11:48 -08:00
David Eberly 569f31f01e Merge pull request #162 from CodeReclaimers/fix/dist-point3-tet-barycentric
Fix barycentric coordinates not stored in DistPoint3Tetrahedron3
2026-02-27 16:11:13 -08:00
David Eberly b3da538a14 Merge pull request #161 from CodeReclaimers/fix/intr-line3-torus3-comment
Fix reversed radius inequality in IntrLine3Torus3.h comment
2026-02-27 16:09:48 -08:00
David Eberly 66732363b4 Merge pull request #160 from CodeReclaimers/fix/transform-inverse-vec-mat
Fix Transform::Inverse() for GTE_USE_VEC_MAT convention
2026-02-27 16:09:15 -08:00
David Eberly 0b5ae8f2a6 Merge pull request #159 from CodeReclaimers/fix/roots-bisection-misleading-return
Fix RootsBisection::Find misleading return when maxIterations < 2
2026-02-27 16:08:15 -08:00
David Eberly 1915e872b3 Merge pull request #158 from CodeReclaimers/fix/timer-getseconds-precision
Fix Timer::GetSeconds() precision truncation
2026-02-27 16:06:31 -08:00
David Eberly 7360d5f89d Merge pull request #157 from CodeReclaimers/fix/thread-safe-lock-guard
Use std::lock_guard for exception safety in ThreadSafeMap and ThreadSafeQueue
2026-02-27 16:06:05 -08:00
David Eberly 93aad85140 Merge pull request #156 from CodeReclaimers/fix/appr-query-negative-indices
Add negative index check in ApprQuery::ValidIndices
2026-02-27 16:05:35 -08:00
David Eberly 85848353e2 Merge pull request #155 from CodeReclaimers/fix/appr-3d-isfinite-mean2
Add missing std::isfinite check for mean[2] in 3D approximation classes
2026-02-27 16:05:09 -08:00
David Eberly 20bfd2bfe7 Merge pull request #154 from CodeReclaimers/fix/appr-torus3-jacobian
Fix Jacobian computation errors in ApprTorus3 torus fitting
2026-02-27 16:04:03 -08:00
David Eberly fbe9caa796 Merge pull request #153 from CodeReclaimers/fix/appr-polynomial-special-overallocation
Fix mParameters overallocation in ApprPolynomialSpecial3 and ApprPolynomialSpecial4
2026-02-27 16:03:27 -08:00
David Eberly e85264eec0 Merge branch 'master' into fix/appr-polynomial-special-overallocation 2026-02-27 16:03:19 -08:00