Here is one possibility to get you close:

vert.x <- c(0,0,1,1)
vert.y <- c(0,1,1,0)

myfun <- function(theta) {
x <- theta[1]
y <- theta[2]
r <- theta[3]

dists <- r - sqrt( (vert.x-x)^2 + (vert.y-y)^2 )
sum( dists^2 ) + 10*sum(dists<0)
}

out <- optim( c(0,0,5), myfun )
out


plot( -1:2, -1:2, type='n', xlab='', ylab='', asp=1 )
polygon(vert.x, vert.y)

theta <- seq(0,2*pi, length.out=250)
polygon( out$par[1] + out$par[3]*cos(theta),
out$par[2] + out$par[3]*sin(theta), border='blue' )

tmp.x <- rnorm(25)
tmp.y <- rnorm(25)
tmp <- chull(tmp.x,tmp.y)

vert.x <- tmp.x[tmp]
vert.y <- tmp.y[tmp]

plot(vert.x, vert.y, xlim=c(-3,3), ylim=c(-3,3))
polygon(vert.x,vert.y)

out <- optim( c(0,0,3), myfun )
out

theta <- seq(0,2*pi, length.out=250)
polygon( out$par[1] + out$par[3]*cos(theta),
out$par[2] + out$par[3]*sin(theta), border='blue' )



On Thu, Jan 24, 2013 at 7:19 AM, Mathieu Rajerison <
mathieu.rajerison@gmail.com> wrote:

> I made a little mistake. The formula is 1 - area(shape) / area(circum),
> not 1 - area(circum) / area(shape)
>
> 2013/1/24 Mathieu Rajerison <mathieu.rajerison@gmail.com>
>
> > Hi,
> >
> >
> > I know spatstat::incircle to calculate the inscribed circle of a shape.
> >
> > I'd like to know if there was a function to calculate the circumscribing
> > circle of a polygon.
> >
> > The area of this circumscribing circle could then be used to calculate a
> > linearity index: 1 - area(circum) / area(shape)
> >
> > For a triangle, the circumcenter is at the intersection of the different
> > perpendicular bisectors of its sides and each corner would be at the same
> > distance to this center, distance being known as circumradius.
> >
> > For a polygon, it seems to me it's a lot more complicated.
> >
> > It's more a geometrical problem than a spatial one but if anyone has an
> > advice, I'd be glad of it..
> >
> >
> > Mathieu
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com

	[[alternative HTML version deleted]]

