Paul Heidmann Fractal Example  1.0
fractalParams.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // Copyright (C) 2014 Paul S. Heidmann
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // For a copy of the GNU General Public License see
16 // <http://www.gnu.org/licenses/>.
17 //
18 // Author contact info:
19 // Paul Heidmann
20 // paul@heidmann.com
21 
22 #include <tuple>
23 #include <vector>
24 #include <cstdint>
25 #include <complex>
26 #include <functional>
27 
28 namespace fractal
29 {
30 
31 /// \brief This class is a container class for the parameters that are
32 /// used to generate a fractal.
33 ///
34 /// This class is a container class for all of the parameters needed to
35 /// generate a fractal.
36 /// \tparam floatType The floating point type on which all parameters
37 /// are based.
38 /// \author Paul S. Heidmann
39 template<typename floatType>
41 {
42 public:
43 
44  /// \brief This type is used to declare variables that hold the complex
45  /// numbers used in the fractal computations.
46  typedef std::complex<floatType> cmplxType;
47 
48  /// \brief This type is used to declare variables that hold the function
49  /// that defines the factal (and its derivative).
50  typedef std::function<cmplxType(const cmplxType&)> funcType;
51 
52  /// \brief This type is used to declare variables that hold the list
53  /// of zeros of the function being used to generate the
54  /// fractal (yes, these need to be known in advance).
55  typedef std::vector<cmplxType> zerosLstType;
56 
57  /// \brief This type is used to declare variables that hold the color
58  /// of a given pixel in the fractal.
59  typedef std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> colorType;
60 
61  /// \brief This type is used to define variables that hold functions
62  /// that map fractal computation results to a color.
63  ///
64  /// In these functions, the first parameter is the maximum number
65  /// of iterations allowed. The second parameter is the zero reached.
66  /// The third parameter is the actual number of iterations.
67  typedef std::function<colorType(
68  const std::uint32_t,
69  const std::complex<floatType>&,
70  const std::uint32_t)> colorMapFuncType;
71 
72  /// \brief This constant attribute holds the lower left coordinate of the
73  /// fractal in the complex plain.
75 
76  /// \brief This constant attribute holds the upper right coordinate of the
77  /// fractal in the complex plain.
79 
80  /// \brief This constant attribute holds the distance between points in
81  /// the fractal. Note that this is a complex number, with the real
82  /// portion being the distance between the real components of two
83  /// neighboring points, and the imaginary component being the
84  /// distance between the imaginary components of two neighboring
85  /// points.
87 
88  /// \brief This constant attribute holds the required accuracy that
89  /// Newton's method is required to produce when searching for
90  /// a zero.
91  const floatType zeroEpsilon;
92 
93  /// \brief This constant attribute holds the function used to produce
94  /// the fractal.
95  const funcType f;
96 
97  /// \brief This constant attribute holds the derivative of the function
98  /// used to produce the fractal.
100 
101  /// \brief This constant attribute holds the list of zeros of the function
102  /// that is generating the fractal.
104 
105  /// \brief This constant attribute holds the maximum number of iterations
106  /// that Newton's method is allowed.
107  const std::uint32_t maxIterations;
108 
109  /// \brief This constant attribute holds the function that maps the output
110  /// of Newton's method to a color.
112 
113  fractalParams() = delete;
114 
115  /// \brief This is the constructor that must be used to create instances
116  /// of this class.
117  /// \note For a description of the parameters of this constructor, see
118  /// the descriptions of the public, constant attributes of this
119  /// class.
121  const cmplxType& lwrLftExtnt,
122  const cmplxType& upprRghtExtnt,
123  const cmplxType& dlt,
124  const floatType& zEpsln,
125  const funcType& fractalFunc,
126  const funcType& derivativeFractalFunc,
127  const zerosLstType& fractalFuncZeros,
128  const std::uint32_t maxIters,
129  const colorMapFuncType& clrMapFunc ) :
130  lowerLeftExtent{ lwrLftExtnt },
131  upperRightExtent{ upprRghtExtnt },
132  delta{ dlt },
133  zeroEpsilon{ zEpsln },
134  f{ fractalFunc },
135  f_prime{ derivativeFractalFunc },
136  f_zeros{ fractalFuncZeros },
137  maxIterations{ maxIters },
138  colorMapFunc{ clrMapFunc }
139  {
140  }
141 
142  /// \brief The class destructor.
144 
145 };
146 
147 }
const funcType f
This constant attribute holds the function used to produce the fractal.
const funcType f_prime
This constant attribute holds the derivative of the function used to produce the fractal.
std::tuple< std::uint8_t, std::uint8_t, std::uint8_t > colorType
This type is used to declare variables that hold the color of a given pixel in the fractal...
const colorMapFuncType colorMapFunc
This constant attribute holds the function that maps the output of Newton&#39;s method to a color...
const floatType zeroEpsilon
This constant attribute holds the required accuracy that Newton&#39;s method is required to produce when ...
const cmplxType delta
This constant attribute holds the distance between points in the fractal. Note that this is a complex...
std::function< cmplxType(const cmplxType &)> funcType
This type is used to declare variables that hold the function that defines the factal (and its deriva...
std::vector< cmplxType > zerosLstType
This type is used to declare variables that hold the list of zeros of the function being used to gene...
const cmplxType lowerLeftExtent
This constant attribute holds the lower left coordinate of the fractal in the complex plain...
const zerosLstType f_zeros
This constant attribute holds the list of zeros of the function that is generating the fractal...
std::complex< floatType > cmplxType
This type is used to declare variables that hold the complex numbers used in the fractal computations...
This class is a container class for the parameters that are used to generate a fractal.
const cmplxType upperRightExtent
This constant attribute holds the upper right coordinate of the fractal in the complex plain...
std::function< colorType(const std::uint32_t, const std::complex< floatType > &, const std::uint32_t)> colorMapFuncType
This type is used to define variables that hold functions that map fractal computation results to a c...
~fractalParams()
The class destructor.
const std::uint32_t maxIterations
This constant attribute holds the maximum number of iterations that Newton&#39;s method is allowed...
fractalParams(const cmplxType &lwrLftExtnt, const cmplxType &upprRghtExtnt, const cmplxType &dlt, const floatType &zEpsln, const funcType &fractalFunc, const funcType &derivativeFractalFunc, const zerosLstType &fractalFuncZeros, const std::uint32_t maxIters, const colorMapFuncType &clrMapFunc)
This is the constructor that must be used to create instances of this class.