View source: R/inscribeEllipse.r
inscribeEllipseRot | R Documentation |
Inscribe the maximum ellipse into any arbitrary 2D polygon including rotations
inscribeEllipseRot(poly, step = 0.3, iters = 999, rotsteps = 45)
poly |
k x 2 matrix containing ordered coordinates forming the polygon |
step |
stepsize |
iters |
integer: number of iterations to run |
rotsteps |
integer: number rotational steps |
center |
center of ellipse |
radius.x |
x-dim of ellipse |
radius.y |
y-dim of ellipse |
maxarea |
area of ellipse |
theta |
angle of optimal rotation |
polyRot |
k x 2 matrix of cooridnates rotated around barycenter to maximize ellipse area |
require(shapes)
require(DescTools)
poly <- gorf.dat[c(1,6:8,2:5),,1]
## Not run:
myellipse <- inscribeEllipseRot(poly,iters = 999,rotsteps=10)
plot(poly,asp=1)
lines(rbind(poly,poly[1,]))
DrawEllipse(x=myellipse$center[1],y=myellipse$center[2],radius.x=myellipse$radius.x,
radius.y = myellipse$radius.y,col="red")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.