Add tetrahedral interpolation for 3D table lookups and tests. - #202
Add tetrahedral interpolation for 3D table lookups and tests.#202aforsythe wants to merge 2 commits into
Conversation
lookup3DTetra splits each cell into six tetrahedra around its main diagonal and blends the four corners of the one holding the sample point. lookup3D's trilinear blend uses all eight corners instead. Exposed through the SIMD stdlib as lookup3DTetra_f3, _f and _h, matching the lookup3D set. Both share a single dispatch parameterised on the interpolation function. Signed-off-by: Alex Forsythe <aforsythe@oscars.org>
testLookup3D cannot see tetrahedron selection: its probes land on grid corners, and its table is linear along each axis, which all six tetrahedra reproduce identically. testLookup3DTetraBranches probes each tetrahedron with distinct non-zero fractional coordinates against a table whose corners sit off the trilinear plane, and its expected values are ones no other tetrahedron produces. Failures name the tetrahedron and component. Checks with an explicit test rather than assert, which Release builds compile out via NDEBUG. Signed-off-by: Alex Forsythe <aforsythe@oscars.org>
|
I have not yet had a chance to compare your nested if structure myself, but any idea if the edge case decisions (i.e. when a point falls on the face between two tetrahedra) align with the math provisioned in CLF standard (ST 2163-1, Formula A.7)? |
|
The SMPTE CLF stnard was my reference for the implementation actually. Went with the nested ifs to match lookup3D right above it, which does trilinear by just blending the corner values instead of the matrix form in teh standard. A7's T matrices are mostly zeros anyway, so writing them out literally is 32 multiplies and adds per sample when all you really need is to blend four corners. Tetrahedra and weights come out the same either way. Results match to rounding error and for points sitting on a face both end up in a tetrahedron that contains the point and give the same answer becuase the corner seperating the two has weight zero. Can add a comment pointing at 2136-1 Formula A.7 if that's useful. |
|
can you also add documentation for these new functions to the CTL manual - /doc/CtlManual.doc and corresponding PDF? |
lookup3DTetrasplits each cell into six tetrahedra and blends the four corners of the one holding the sample point. The existinglookup3Dblends all eight corners of the cell. Most LUT formats assume tetrahedral interpolation.Available from CTL as
lookup3DTetra_f3,lookup3DTetra_fandlookup3DTetra_h, matching the existinglookup3Dset.Includes a test that probes all six tetrahedra.
Closes #203
Category: new features
Test generation, code style compliance, and documentation Assisted-by: Calude-4.8-Opus