BinToKamaeScale.cxx

Go to the documentation of this file.
00001 
00012 #include "BinToKamaeScale.h"
00013 
00014 #include <cmath>
00015 
00016 #include <cassert>
00017 
00018 namespace hippodraw {
00019 
00020 BinToKamaeScale::
00021 BinToKamaeScale ( const char * name )
00022   : BinToColor ( name )
00023 {
00024 }
00025 
00026 BinToKamaeScale::BinToKamaeScale ( const BinToKamaeScale & bin_to_color )
00027   : BinToColor ( bin_to_color )
00028 {
00029 }
00030 
00031 BinToColor * BinToKamaeScale:: clone () const
00032 {
00033   return new BinToKamaeScale ( *this );
00034 }
00035 
00036 void
00037 BinToKamaeScale::
00038 doubleToColor ( double value, Color & color ) const
00039 {
00040    double z = ( value - m_vmin ) / m_dv;
00041    z = std::max ( 0.0, z );
00042    z = std::min ( 1.0, z );
00043 
00044    double r = std::min ( 255., 
00045                          113.9 * sin ( 7.64 * pow ( z, 1.705 ) + 0.701 )
00046                          - 916.1 * pow ( ( z + 1.755), 1.862 )
00047                          + 3587.9 * z + 2563.4 );
00048    double g = std::min ( 255.,
00049                          70.0 * sin ( 8.7 * pow ( z, 1.26 ) - 2.418 )
00050                          + 151.7 * pow ( z, 0.5 )
00051                          + 70.0 );
00052    double b = std::min ( 255.,
00053                          194.5 * pow ( z, 2.88 )
00054                          + 99.72 * exp ( -77.24 *pow ( z - 0.742, 2 ) )
00055                          + 45.4 * pow ( z, 0.089 )
00056                          + 10.0 );
00057 
00058    int red   = static_cast < int > ( r );
00059    int green = static_cast < int > ( g );
00060    int blue  = static_cast < int > ( b );
00061 
00062    assert ( red < 256 && green < 256 && blue < 256 );
00063    color.setColor ( red, green, blue );
00064 }
00065 
00066 } // namespace hippodraw
00067 

Generated for HippoDraw Class Library by doxygen