java - Equation-driven smoothly shaded concentric shapes -
background
looking create interesting video transitions (in grayscale).
problem
given equations represent closed, symmetrical shape, plot outline , concentrically shade shape towards centre.
example
consider following equations:
x = 16 * sin(t)^3 y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t) t = [0:2 * pi]
when plotted:
when shaded, resemble (not shown shaded, sufficient show idea):
notice shading darkest on outside (e.g., #000000 rgb hex), lightens fills centre. centre white (e.g., #ffffff) dot.
questions
- what expedient way produce high-resolution, concentrically shaded grayscale images, such shaded heart above?
- what such closed, symmetrical shapes formally called?
thank you!
ideas
- use library such http://code.google.com/p/jmathplot/
- use gnuplot
- use r
- plot using wolfram alpha, use imagemagick create smaller concentric versions
try in r:
# create palette greyscale <- colorramppalette(c("black","white")) # function draw shape plotheart <- function(r, col){ t <- seq(0,2*pi,length.out=100) x <- r*sin(t)^3 y <- (13*r/16)*cos(t) - (5*r/16)*cos(2*t) - (2*r/16)*cos(3*t) - (r/16)*cos(4*t) polygon(x,y,col=col,border=na) } # create new plot canvas plot.new() # limits approximate here plot.window(xlim=c(-16,16),ylim=c(-16,13)) # use mapply loop mapply(plotheart,seq(16,0,length.out=100),greyscale(100))
which results in:
this works repeated drawing filled polygons of decreasing size , different colour atop of 1 another. answer questions:
(1) produced machine (a modest core 2 duo laptop) in 0.09 seconds. may other languages/implementations faster, seems quick enough me.
(2) planar shape made of lines not cross other called simple polygon.
Comments
Post a Comment