///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2006 James M. Lawrence. All rights reserved. // // software: esve-1.0.3 // file: examples/monomial/monomial.cxx // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. The origin of this software must not be misrepresented; you must // not claim that you wrote the original software. If you use this // software in a product, an acknowledgment in the product // documentation would be appreciated but is not required. // // 3. Altered source versions must be plainly marked as such, and must // not be misrepresented as being the original software. // // 4. The name of the author may not be used to endorse or promote // products derived from this software without specific prior written // permission. // // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY, // AND WITH NO CLAIM AS TO ITS SUITABILITY FOR ANY PURPOSE. IN NO EVENT // SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM WHATSOEVER MADE IN CONNECTION // TO THIS SOFTWARE. // ///////////////////////////////////////////////////////////////////////// #include #include #include using esve::viewers::dim4::Surface_Viewer ; using esve::geom::dim4::specs::Polar_Annulus ; //////////////////////////////////////////////////////////// // // help // //////////////////////////////////////////////////////////// const std::string HELP = "\n" "The complex function\n" "\n" " f(z) = z^p - r.\n" "\n" "for real p and real r.\n" "\n" "The 'power' parameter corresponds to p and the 'root radius'\n" "parameter corresponds to r.\n" "\n" "The 'inversion' parameter is the reciprocal of the point at infinity.\n" "\n" ; //////////////////////////////////////////////////////////// // // Monomial // //////////////////////////////////////////////////////////// struct Monomial : public Polar_Annulus { real scale_fz ; real power ; real root_radius ; real scale_color ; Monomial() : Polar_Annulus(0.1, 1.0), scale_fz(1.0), power(3.0), root_radius(0.0), scale_color(0.7) { } quat surface( const complex & unit_square, const complex & domain ) const { const complex fz = pow(domain, power) - root_radius ; return quat(scale_fz*fz.imag(), domain.real(), domain.imag(), scale_fz*fz.real()) ; } rgba color( const complex & unit_square, const complex & domain, const quat & surface ) const { return rgba::from_hsva( std::min( abs(domain)*scale_color, real(0.7)), 0.8, 0.8, 1.0) ; } } ; //////////////////////////////////////////////////////////// // // Viewer // //////////////////////////////////////////////////////////// struct Viewer : public Surface_Viewer { Viewer( int argc, char** argv ) : Surface_Viewer(argc, argv, "monomial") { create_help(HELP + help_text()) ; create_scaling_valuator().value(1) ; create_resolution_valuator().value(30, 200) ; create_label("domain") ; create_valuator(&Monomial::inner_radius, &Monomial::inner_radius, CHANGES_DOMAIN).step(0.001).range(0.0001, MAX_REAL) ; create_valuator(&Monomial::outer_radius, &Monomial::outer_radius, CHANGES_DOMAIN).step(0.001).range(0.0001, MAX_REAL) ; create_valuator(&Monomial::scale_fz, CHANGES_SURFACE, "scale f(z)").step(0.001).range(0, MAX_REAL) ; create_valuator(&Monomial::power, CHANGES_SURFACE, "power").step(0.01) ; create_valuator(&Monomial::root_radius, CHANGES_DOMAIN, "root radius").step(0.001).range(0, MAX_REAL) ; create_valuator(&Monomial::scale_color, CHANGES_COLOR, "scale color").step(0.005).range(0, MAX_REAL) ; create_inversion_valuator().value(0) ; create_hide_back_toggle() ; } } ; //////////////////////////////////////////////////////////// // // main // //////////////////////////////////////////////////////////// int main( int argc, char** argv ) { Viewer viewer(argc, argv) ; return viewer.takeover() ; }