r - 根据“样条”多项式旋转数据有问题吗?
问题描述
这是问题所在的代码:
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。
解决方案
已解决:R 三角函数使用弧度,因此脚本不必要地转换为度数并导致在 180/pi 的比例下过度校正。
推荐阅读
- python - valueerror array is too big arr.size when merge and sum based on title than 2 data frame
- python - 在图像中找到对象和背景具有几乎相同颜色的轮廓
- c++ - 使用 std::launder 从指向非活动联合成员的指针中获取指向活动联合成员的指针?
- javascript - 如何在事件处理程序上访问 Javascript For Loop 上的正确索引
- eclipse - 启动捆绑包时缺少要求 osgi.wiring.package
- machine-learning - 特征选择应该在训练测试拆分之前还是之后完成?
- android - 尝试从android中的列表中删除某些项目时出现ConcurrentModificationException
- java - 合并排序算法的问题
- node.js - 获取属性猫鼬的数组长度
- c# - HTTP POST 请求被阻止的跨域请求