首页 > 解决方案 > 根据“样条”多项式旋转数据有问题吗?

问题描述

这是问题所在的代码:

angles = -atan(deriv)

angles = angles*(180/pi)



#shift coordinates onto their polynomials

d[1:mtp,3] = d[1:mtp,3] + poly[,2]



#rotated storage matrix

rrr = as.data.frame(matrix(data = NA, ncol = 2, nrow = 9000))



#for each moment, take in old coordinates and export newly rotated

for(i in 1:mtp){

rotm = matrix(data = c(c(cos(angles[i]),sin(angles[i])),

c(-sin(angles[i]),cos(angles[i]))), ncol=2, nrow = 2)

rotate.1 = d[i,2:3] - poly[i,]

rotate.2 = rotm %*% t(rotate.1)

rotate.3 = rotate.2 + poly[i,]

rrr[i,] = rotate.3

}



#overwrite coordinates with rotations

d[1:mtp,2:3] = rrr

“deriv”是一个数值向量,包含沿多项式样条“poly”的每个点的导数,其中 x 和 y 列为 1:2。因此,“角度”包含计算出的每个点的旋转角度。“d”是初始数据矩阵,第 2:3 列是 x 和 y。

要翻译和旋转的数据

“样条”多项式,数据将沿该多项式进行平移和旋转

旋转过程中沿多项式使用的角度(衍生自导数)

数据+样条(翻译)

翻译和(错误地)旋转的数据

标签: rrotationsplinepolynomialsderivative

解决方案


已解决:R 三角函数使用弧度,因此脚本不必要地转换为度数并导致在 180/pi 的比例下过度校正。


推荐阅读