所以你现在拥有的是共面点3D的坐标(你可以通过计算矩阵的等级my.plain [,c(“x”,“y”,“z”)来确认你的点是共面的] ,这是2).
您希望新的“框架”由点A定义为原点和矢量(A-> B)/ | A-> B | ^ 2和(A-> D)/ | A-> D | ^ 2.
要将xyz坐标转换为新“框架”中的坐标,您需要将以前坐标(乘以A的坐标)乘以从旧框架到新框架的转换矩阵.
所以,在R代码中,这给出了:
# Get a matrix out of your data.frame
row.names(my.plain)
my.plain
# compute the matrix of transformation
require(Matrix)
AB
AD
tr_mat
# compute the new coordinates
my.plain.2D
# plot the 2D data
plot(my.plain.2D, pch=19, las=1, xlab="x", ylab="y")
# and the plot with the letters, the polygon and the color:
plot(my.plain.2D, pch=3, las=1, xlab="x", ylab="y")
polygon(my.plain.2D[c("A", "B", "C", "F", "H", "G", "D"), ], col="magenta")
points(my.plain.2D, pch=3, lwd=2)
text(my.plain.2D[, 1], my.plain.2D[, 2], row.names(my.plain.2D), pos=2, font=2)