顺序向量的转角:复平面

问题描述

我正在尝试计算复平面中顺序向量的转角。请参阅下面的代码获取演示数据框和我计算角度的尝试。

角度的符号似乎正确:左转为正,右转为负。但是,当我参考绘图时,转角看起来不正确。注意:我想要转动角度而不是矢量之间的角度。图片供参考:

enter image description here

set.seed(123)

# Generate a random path and plot it
path.short.random <- function(points = 6) {
  x <- runif(points,-1,1)
  y <- rnorm(points,0.25)
  i <- order(x,y)
  x <- x[i]
  y <- y[i]
  path <- data.frame(x = x,y = y)
  plot(x,y,main = "Random Path",asp = 1)
  # draw arrows from point to point
  s <- seq(length(x) - 1)  # one shorter than data
  arrows(x[s],y[s],x[s + 1],y[s + 1],col = 1:points)
  path
}

# Save the path as a data frame
df <- path.short.random()

# Compute sequential turning angles
get.angles <- function(df) {
  df$polar <- complex(real = df$x,imaginary = df$y)
  df$displacement <- c(0,diff(df$polar))
  diff(Arg(df$displacement[2:nrow(df)]))
}

get.angles(df)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)