BinToKamaeScale.cxx
Go to the documentation of this file.
1 
12 #include "BinToKamaeScale.h"
13 
14 #include <cmath>
15 
16 #include <cassert>
17 
18 namespace hippodraw {
19 
21 BinToKamaeScale ( const char * name )
22  : BinToColor ( name )
23 {
24 }
25 
27  : BinToColor ( bin_to_color )
28 {
29 }
30 
32 {
33  return new BinToKamaeScale ( *this );
34 }
35 
36 void
38 doubleToColor ( double value, Color & color ) const
39 {
40  double z = ( value - m_vmin ) / m_dv;
41  z = std::max ( 0.0, z );
42  z = std::min ( 1.0, z );
43 
44  double r = std::min ( 255.,
45  113.9 * sin ( 7.64 * pow ( z, 1.705 ) + 0.701 )
46  - 916.1 * pow ( ( z + 1.755), 1.862 )
47  + 3587.9 * z + 2563.4 );
48  double g = std::min ( 255.,
49  70.0 * sin ( 8.7 * pow ( z, 1.26 ) - 2.418 )
50  + 151.7 * pow ( z, 0.5 )
51  + 70.0 );
52  double b = std::min ( 255.,
53  194.5 * pow ( z, 2.88 )
54  + 99.72 * exp ( -77.24 *pow ( z - 0.742, 2 ) )
55  + 45.4 * pow ( z, 0.089 )
56  + 10.0 );
57 
58  int red = static_cast < int > ( r );
59  int green = static_cast < int > ( g );
60  int blue = static_cast < int > ( b );
61 
62  assert ( red < 256 && green < 256 && blue < 256 );
63  color.setColor ( red, green, blue );
64 }
65 
66 } // namespace hippodraw
67 

Generated for HippoDraw Class Library by doxygen