MCPcopy Create free account
hub / github.com/ImageEngine/cortex / monotoneSlopeCompute

Function monotoneSlopeCompute

src/IECore/Ramp.cpp:45–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template<typename X, typename Y>
45inline Y monotoneSlopeCompute( const Y& deltaY1, const Y& deltaY2, const X& deltaX1, const X& deltaX2 )
46{
47 // Using this weighted harmonic mean to compute slopes ensures a monotone curve.
48 // This is apparently a result by Fritsch and Carlson, from here:
49 //
50 // F. N. Fritsch and R. E. Carlson
51 // SIAM Journal on Numerical Analysis
52 // Vol. 17, No. 2 (Apr., 1980), pp. 238-246
53 //
54 // Haven't actually gotten ahold of this paper, but stackexchange says that it says this,
55 // and it seems to work quite well.
56 if( deltaY1 * deltaY2 > 0.0f )
57 {
58 return 3.0f * ( deltaX1 + deltaX2 ) / (
59 ( 2.0f * deltaX2 + deltaX1 ) / deltaY1 +
60 ( deltaX2 + 2.0f * deltaX1 ) / deltaY2 );
61 }
62 else
63 {
64 return 0;
65 }
66}
67
68template<>
69inline Imath::Color3f monotoneSlopeCompute<>(

Callers 2

monotoneSlopeCompute<>Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected