title: bivariate inter- and extrapolation to create heatmap that fills up a circle
body: <p>I have several points within a unit circle in 2D. The points (red, green) come from one of two classes.</p>
  
  <pre><code>library(plotrix)
  
  # draw points within circle
  n &lt;- 100
  d &lt;- data.frame(x= rnorm(n), 
                  y= rnorm(n))
  d &lt;- d[sqrt(d$x^2 + d$y^2) &lt; 1, ] 
  d$value &lt;- ifelse(d$x &gt; 0, 2, 3)
  plot(d$x, d$y, xlim=c(-1,1), ylim=c(-1,1), pch=16, asp=1, col=d$value)
  draw.circle(0,0,1)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EdVlz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EdVlz.png" alt="enter image description here"></a></p>
  
  <p>Now I want to overlay the plot with smooth heatmap indicating the region for each group.</p>
  
  <pre><code>library(akima)
  library(scales)
  
  # estimate surface
  nxy &lt;- 100
  xyo &lt;- seq(-1, 1, len=nxy)
  int &lt;- interp(x = d$x, y = d$y, z = d$value, 
                        extrap = T, 
                        xo = xyo, yo = xyo, 
                        nx = nxy, ny=nxy, 
                        linear = T)
  colors &lt;- alpha(colorRampPalette(c("red", "yellow", "green"))(40) , .4)
  image(xyo, xyo, int$z, add = T, col = colors)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EdVlz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6SKOi.png" alt="enter image description here"></a></p>
  
  <p>So far so good. My problem is to find a way to extrapolate the heatmap to the edges of the circle, so it fills up the whole circle. There is an argument <code>extrap</code>. In the docs it says: <code>logical flag: should extrapolation be used outside of the convex hull determined by the data points?</code>. I set it to <code>TRUE</code>, however, this does not seem to work. </p>
  
  <p><strong>Any ideas how to estimate a smooth surface that covers the whole circle?</strong></p>