How to obtain the lengths of semi axes of an ellipse? in R

前端 未结 2 1699
一整个雨季
一整个雨季 2021-01-05 12:54

I have this set of x and y coordinates:

x<-c(1.798805,2.402390,2.000000,3.000000,1.000000)
y<-c(0.3130147,0.4739707,0.2000000,0.8000000,0.1000000)
as.m         


        
2条回答
  •  梦毁少年i
    2021-01-05 13:37

    You can do this:

    exy <- predict(ellipsoidhull(d)) ## the ellipsoid boundary
    me <- colMeans((exy))            ## center of the ellipse
    

    Then you compute the minimum and maximum distance to get respectively minor and major axis:

    dist2center <- sqrt(rowSums((t(t(exy)-me))^2))
    max(dist2center)     ## major axis
    [1] 1.264351
    > min(dist2center)   ## minor axis
    [1] 0.1537401
    

    EDIT plot the ellipse with the axis:

    plot(exy,type='l',asp=1)
    points(d,col='blue')
    points(me,col='red')
    lines(rbind(me,exy[dist2center == min(dist2center),]))
    lines(exy[dist2center == max(dist2center),])
    

    enter image description here

提交回复
热议问题