Нарисовать спицы
Вообще, полагалось бы нарисовать пустотелый Move. Цвета обводки 214478, заливки , 5 изн. пет. Вам нужно будет написать Edit Polyline и выделяем пет. 4 ряд (изнаночный): 2 чередуя их в пет. , 1 изн.
Вот, держи. Вам нужны пакеты sp и rgeos:
spokey <- function(xy,n=20){ xcent = mean(xy[,1]) ycent = mean(xy[,2]) cent = sp::SpatialPoints(cbind(xcent, ycent)) pts = sp::SpatialPoints(xy) ## take the furthest distance from centre to vertex, times two! r = 2 * max(sp::spDistsN1(pts, cent)) theta=seq(0,2*pi,length=n+1)[-(n+1)] ## construct a big wheel of spoke lines sl = sp::SpatialLines( lapply(1:length(theta),function(id){ t = theta[id] sp::Lines( list( sp::Line( rbind( c(xcent, ycent), c(xcent + r * cos(t),ycent + r * sin(t)) ) ) ),ID=id) })) ## construct the polygon as a SpatialPolygons object: pol = sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(rbind(xy,xy[1,]))),ID=1))) ## overlay spokes on polygon as "SpatialLines" so we do line-on-line ## intersect which gets us points spokes = rgeos::gIntersection(sl, as(pol,"SpatialLines"), byid=TRUE) spokes}
Он принимает матрицу координат, в которой первая точка не является последней точкой:
xy1 = structure(c(4.49425847117117, 4.9161781929536, 7.95751618746858, 7.92235621065338, 9.76825499345149, 9.9616348659351, 8.04541612950659, 7.83445626861537, 6.42805719600729, 0.644241009906543, 2.40223985066665, 1.24196061576498, 2.13854002455263, 7.935927470861, 9.41043173309254, 9.33179150577352, 6.50074332228897, 7.34612576596839, 2.76533252463575, 1.07456763727692, 3.88595576393172, 1.17286792142569, 2.745672467806, 5.20317957152522, 5.81264133324759, 8.21116826647756), .Dim = c(13L, 2L))
и затем:
> plot(xy1,asp=1)> polygon(xy1)> spokes = spokey(xy1,20) # second arg is number of spokes> points(spokes,pch=19,col="red")
достает тебя:
Если вы в это не верите, нарисуйте сегменты от центра к точкам :)
segments(mean(xy1[,1]),mean(xy1[,2]), coordinates(spokes)[,1], coordinates(spokes)[,2])
Функция coordinates(spokes)
даст вам двухколоночную матрицу точек спицы-в настоящее время она возвращается как объект SpatialPoints
.