Title: | Generates Views on the Mandelbrot Set |
---|---|
Description: | Estimates membership for the Mandelbrot set. |
Authors: | Ben Moore [aut, cre], Mario dos Reis [aut] |
Maintainer: | Ben Moore <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2025-03-06 04:03:12 UTC |
Source: | https://github.com/blmoore/mandelbrot |
Converts objects produced by mandelbrot
to tidy data.frames for use with ggplot and other tidyverse packages.
## S3 method for class 'mandelbrot' as.data.frame(x, ...)
## S3 method for class 'mandelbrot' as.data.frame(x, ...)
x |
a Mandelbrot set object produced by |
... |
ignored |
a 3-column data.frame
mb <- mandelbrot() df <- as.data.frame(mb) head(df)
mb <- mandelbrot() df <- as.data.frame(mb) head(df)
Generates a view on the Mandelbrot set using an underlying C function.
mandelbrot(xlim = c(-2, 2), ylim = c(-2, 2), resolution = 600, iterations = 50) mandelbrot0(xlim = c(-2, 2), ylim = c(-2, 2), resolution = 600, iterations = 50)
mandelbrot(xlim = c(-2, 2), ylim = c(-2, 2), resolution = 600, iterations = 50) mandelbrot0(xlim = c(-2, 2), ylim = c(-2, 2), resolution = 600, iterations = 50)
xlim |
limits of x axis (real part) |
ylim |
limits of y axis (imaginary part) |
resolution |
either an integer |
iterations |
maximum number of iterations to evaluate each case |
mandelbrot0
is an experimental interface
for generating tidy data.frames faster than
as.data.frame(mandelbrot())
.
a mandelbrot
structure with components: x
a vector
of the real parts of the x-axis; y
the imaginary parts of each
number (the y-axis); z
a matrix of the number of iterations that
In brief, the Mandelbrot set contains the complex numbers
where the 0 orbit of the following function remains
bounded ():
For information and discussion on the Mandelbrot and related sets, one great resource is plus.maths.org. There's also a popular YouTube video by Numberphile.
Wraps original C code by Mario dos Reis, September 2003.
https://stat.ethz.ch/pipermail/r-help/2003-October/039773.html http://people.cryst.bbk.ac.uk/~fdosr01/Rfractals/index.html
Takes a simple palette and expands / oscillates it for use with Mandelbrot sets.
mandelbrot_palette(palette, fold = TRUE, reps = 1L, in_set = "black")
mandelbrot_palette(palette, fold = TRUE, reps = 1L, in_set = "black")
palette |
vector of color hex strings (e.g. '#FFFFFF') |
fold |
wrap or fold the palette back on itself |
reps |
number of times to replicate the color vector |
in_set |
color for areas in the Mandelbrot set |
an extended color vector
view <- mandelbrot(xlim = c(-0.8438146, -0.8226294), ylim = c(0.1963144, 0.2174996), iter = 500) # can be used to simply interpolate a color gradient spectral <- RColorBrewer::brewer.pal(11, "Spectral") cols <- mandelbrot_palette(spectral, fold = FALSE) plot(view, col = cols, transform = "inv") # simple palettes might need folds / reps to look good blues <- RColorBrewer::brewer.pal(9, "Blues") cols <- mandelbrot_palette(blues, in_set = "white", fold = TRUE, reps = 2) plot(view, col = cols, transform = "log")
view <- mandelbrot(xlim = c(-0.8438146, -0.8226294), ylim = c(0.1963144, 0.2174996), iter = 500) # can be used to simply interpolate a color gradient spectral <- RColorBrewer::brewer.pal(11, "Spectral") cols <- mandelbrot_palette(spectral, fold = FALSE) plot(view, col = cols, transform = "inv") # simple palettes might need folds / reps to look good blues <- RColorBrewer::brewer.pal(9, "Blues") cols <- mandelbrot_palette(blues, in_set = "white", fold = TRUE, reps = 2) plot(view, col = cols, transform = "log")
Draws colored set membership using image
.
## S3 method for class 'mandelbrot' plot(x, col = mandelbrot_palette(c("white", grey.colors(50))), transform = c("none", "inverse", "log"), asp = 1, ...)
## S3 method for class 'mandelbrot' plot(x, col = mandelbrot_palette(c("white", grey.colors(50))), transform = c("none", "inverse", "log"), asp = 1, ...)
x |
an object generated by |
col |
a vector of colors, such as those generated by
|
transform |
the name of a transformation to apply to the number of iterations matrix |
asp |
the |
... |
extra arguments passed to |