Skip to content

Commit

Permalink
Discovery start stronger template-rectangle basis
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Sep 7, 2024
1 parent 55431bb commit 8811318
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 123 deletions.
1 change: 1 addition & 0 deletions MandelbrotDiscovery/MandelbrotDiscovery.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<ClInclude Include="..\mandelbrot\text_output.h" />
<ClInclude Include="geometry.h" />
<ClInclude Include="mandelbrot_discovery.h" />
<ClInclude Include="mandelbrot_discovery_type.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="utility.h" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions MandelbrotDiscovery/MandelbrotDiscovery.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<ClInclude Include="resource.h">
<Filter>MandelbrotDiscovery</Filter>
</ClInclude>
<ClInclude Include="mandelbrot_discovery_type.h">
<Filter>MandelbrotDiscovery</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MandelbrotDiscovery.rc">
Expand Down
66 changes: 35 additions & 31 deletions MandelbrotDiscovery/mandelbrot_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,61 @@
//

#include <mandelbrot_discovery.h>
#include <mandelbrot_discovery_type.h>
#include <resource.h>
#include <utility.h>

#include <boost/multiprecision/cpp_dec_float.hpp>

namespace local::cfg
namespace local
{
constexpr int MANDELBROT_COORD_PNT_DIGITS10 = 132;
constexpr int MANDELBROT_ITERATION_DIGITS10 = 132;
constexpr int MANDELBROT_CALCULATION_PIXELS_X = 768;
constexpr int MANDELBROT_CALCULATION_PIXELS_Y = 768;
template<const unsigned Digits10>
struct cfg_type
{
static constexpr auto my_digits10() noexcept -> unsigned { return Digits10; }

using mandelbrot_coord_pnt_type = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<my_digits10()>, boost::multiprecision::et_off>;
using mandelbrot_iteration_type = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<my_digits10()>, boost::multiprecision::et_off>;
};

static constexpr char str_mandelbrot_point_dx_half [] = "+1.35";
static constexpr char str_mandelbrot_point_dy_half [] = "+1.35";
static constexpr char str_mandelbrot_point_center_x[] = "-0.75";
static constexpr char str_mandelbrot_point_center_y[] = "+0.00";
} // namespace local

constexpr char MANDELBROT_POINT_DX_HALF[] = "1.35";
constexpr char MANDELBROT_POINT_DY_HALF[] = "1.35";
constexpr char MANDELBROT_POINT_CENTER_X[] = "-0.75";
constexpr char MANDELBROT_POINT_CENTER_Y[] = "+0.00";
} // namespace local::cfg
//static_assert(local::mandelbrot_calculation_pixels_x == local::mandelbrot_calculation_pixels_y,
// "Error: This program is only compilable for square geometry");

static_assert(local::cfg::MANDELBROT_CALCULATION_PIXELS_X == local::cfg::MANDELBROT_CALCULATION_PIXELS_Y,
"Error: This program is only compilable for square geometry");
//static_assert(util::utility::equal(local::mandelbrot_point_dx_half(),
// local::mandelbrot_point_dx_half() + util::utility::strlen(local::cfg_type_0::mandelbrot_point_dx_half()),
// local::mandelbrot_point_dy_half()),
// "Error: This program is only compilable for square geometry");

static_assert(util::utility::equal(local::cfg::MANDELBROT_POINT_DX_HALF,
local::cfg::MANDELBROT_POINT_DX_HALF + sizeof(local::cfg::MANDELBROT_POINT_DX_HALF),
local::cfg::MANDELBROT_POINT_DY_HALF),
"Error: This program is only compilable for square geometry");
template<const unsigned Digits10> auto dx_half () -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_dx_half }; }
template<const unsigned Digits10> auto dy_half () -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_dy_half }; }
template<const unsigned Digits10> auto center_x() -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_center_x }; }
template<const unsigned Digits10> auto center_y() -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_center_y }; }

using mandelbrot_coord_pnt_type = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<local::cfg::MANDELBROT_COORD_PNT_DIGITS10>, boost::multiprecision::et_off>;
using mandelbrot_iteration_type = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<local::cfg::MANDELBROT_ITERATION_DIGITS10>, boost::multiprecision::et_off>;
template<const unsigned Digits10>
using rectangle_from_digits_type = geometry::rectangle_type<typename geometry::point_type<typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type>>;

inline auto dx_half() -> mandelbrot_coord_pnt_type { return mandelbrot_coord_pnt_type(local::cfg::MANDELBROT_POINT_DX_HALF); }
inline auto dy_half() -> mandelbrot_coord_pnt_type { return mandelbrot_coord_pnt_type(local::cfg::MANDELBROT_POINT_DY_HALF); }
inline auto center_x() -> mandelbrot_coord_pnt_type { return mandelbrot_coord_pnt_type(local::cfg::MANDELBROT_POINT_CENTER_X); }
inline auto center_y() -> mandelbrot_coord_pnt_type { return mandelbrot_coord_pnt_type(local::cfg::MANDELBROT_POINT_CENTER_Y); }
constexpr inline auto default_digits10() -> unsigned { return 132U; }

using local_window_type = mandelbrot_discovery<static_cast<int>(INT16_C(800)),
static_cast<int>(INT16_C(800)),
mandelbrot_coord_pnt_type,
mandelbrot_iteration_type,
rectangle_from_digits_type<default_digits10()>,
mandelbrot_discovery_detail::WindowTitleDefault,
IDI_MANDELBROT_DISCO>;

using point_type = typename local_window_type::point_type;
using rectangle_type = typename local_window_type::rectangle_type;
using rectangle_type = rectangle_from_digits_type<default_digits10()>;
using point_type = typename rectangle_type::point_type;

auto rectangle() -> rectangle_type&
{
static rectangle_type my_rect
{
point_type { center_x(), center_y() },
dx_half(),
dy_half()
point_type { center_x<default_digits10()>(), center_y<default_digits10()>() },
dx_half<default_digits10()>(),
dy_half<default_digits10()>()
};

static const bool result_pixel_assoc_is_ok { my_rect.set_pixel_assoc(768, 768) };
Expand Down
Loading

0 comments on commit 8811318

Please sign in to comment.