R 中的最小二乘三角剖分

Least Squares Triangulation in R

给定已知坐标的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"形式的数据?

这可能是一个开始。我认为有一些方法可以使方程线性化,从而简化程序。但是,这只是采用找到三个圆的交点的明显方法,并使用 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)