【问题标题】:Least Squares Triangulation in RR中的最小二乘三角剖分
【发布时间】:2016-01-12 18:54:15
【问题描述】:

如果给定已知坐标的 3 个点的距离观测值,未知点的坐标是什么?

例如:

x = c(30.0,10.0,50.0)
y = c(150.0,120.0,50.0)
distance = c("125.0 ± 0.5","133.5 ± 0.2","98.6 ± 0.2")
df = data.frame(x, y, distance) 

是否可以使用 R 使用最小二乘法和 (a) 间接观测法和 (b) 条件方程来计算未知点的坐标?

R中如何导入“125.0±0.5”形式的数据?

【问题讨论】:

  • “125.0 ± 0.5”形式的数据将以“字符”模式导入。然后,您可以使用strsplit 将其拆分,并将结果强制转换为“数字”。您还应该澄清实际需要什么。什么是“未知点”?那些“硬”边缘是中心周围隐含的上下半径,还是这些不确定性界限有统计方面的问题?半径是否与中心按顺序关联?

标签: r triangulation least-squares


【解决方案1】:

这可能是一个开始。我认为有一些方法可以使方程线性化,从而简化程序。但是,这只是采取了寻找三个圆的交点的明显方法,并使用nlm 来最小化正方形。我根本不处理这里的错误。

## Your data
x = c(30.0,10.0,50.0)
y = c(150.0,120.0,50.0)
## distance = c("125.0 ± 0.5","133.5 ± 0.2","98.6 ± 0.2")
dists <- c(125, 133.5, 98.6)  # simplified

## Minimize this function:
## x: guesstimates
## centers: fixed points (x, y)
## b: distances
f <- function(x, centers, b) {
    sqrt(sum((sqrt(colSums((x - centers)^2)) - b)^2))
}

## Get estimate: initial guess of c(100, 100)
centers <- matrix(c(x, y), nrow=2, byrow=TRUE)
res <- nlm(f, c(100, 100), centers=centers, b=dists)

## Lets visualize to see if it worked
circle <- function(x, y, d, col='black') {
    theta <- seq(0, 2*pi, length.out=100)
    data.frame(x=d*cos(theta)+x, y=d*sin(theta)+y, col, stringsAsFactors=FALSE)
}
cols <- colorRampPalette(c('blue', 'red'))(3)
circs <- Map(circle, x, y, dists, cols)
ps <- do.call(rbind, circs)
plot(ps[1:2], type='n')
grid()
abline(h=0, v=0)
points(x, y, col=cols, pch=16, cex=2)
for (i in circs) points(i[1:2], col=i$col, type='l')

## Add the estimated point
points(x=res$estimate[1], y=res$estimate[2], 
       col='firebrick', pch=8, cex=2)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-28
    • 1970-01-01
    • 2015-01-07
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 2019-04-18
    • 2013-09-17
    相关资源
    最近更新 更多