| 43 | |
| 44 | template<typename X, typename Y> |
| 45 | inline 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 | |
| 68 | template<> |
| 69 | inline Imath::Color3f monotoneSlopeCompute<>( |
no outgoing calls
no test coverage detected