Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何解释“形状”包的矢量角度?_R_Trigonometry - Fatal编程技术网

R 如何解释“形状”包的矢量角度?

R 如何解释“形状”包的矢量角度?,r,trigonometry,R,Trigonometry,我想弄清楚我用的一些向量角是否计算正确 我有一个模拟的粒子轨迹,数据如下: track_id track_length frame x y dx dy steplength direction <fctr> <fctr> <dbl> <dbl> <dbl> <dbl>

我想弄清楚我用的一些向量角是否计算正确

我有一个模拟的粒子轨迹,数据如下:

   track_id       track_length frame          x         y         dx           dy steplength   direction
     <fctr>             <fctr> <dbl>      <dbl>     <dbl>      <dbl>        <dbl>      <dbl>       <dbl>
 1  Track 1 Track length:  464     0 -0.2779444 0.6532534  0.0000000  0.000000000  0.0000000   0.0000000
 2  Track 1 Track length:  464     1  0.9527568 1.6890017  1.2307012  1.035748375  1.6085398  40.0836991
 3  Track 1 Track length:  464     2  3.1617740 1.5406508  2.2090172 -0.148350899  2.2139930  -3.8420418
 4  Track 1 Track length:  464     3  3.4791213 1.1602548  0.3173472 -0.380396044  0.4953892 -50.1632825
 5  Track 1 Track length:  464     4  3.0130556 1.7207842 -0.4660657  0.560529394  0.7289790 129.7426481
 6  Track 1 Track length:  464     5  4.1270750 1.7163850  1.1140194 -0.004399235  1.1140281  -0.2262584
 7  Track 1 Track length:  464     6  3.5344773 2.2045875 -0.5925977  0.488202537  0.7677980 140.5171189
 8  Track 1 Track length:  464     7  1.8244100 2.3753219 -1.7100673  0.170734431  1.7185693 174.2984400
 9  Track 1 Track length:  464     8  3.2462738 1.7072696  1.4218637 -0.668052374  1.5709839 -25.1661450
10  Track 1 Track length:  464     9  2.0981822 2.1773816 -1.1480916  0.470112097  1.2406126 157.7322425
if (angle < 0)
    angle = angle + 360
方向列的计算方式如下:

方向=180/pi*atan2dy,dx

这给了我一个角度,每个点的向量,以[-180,180]度的形式。我检查了ggplot的箭头功能,角度看起来是正确的。到目前为止还不错

现在,我想使用光栅和图形包的组合来绘制每个xy单元的矢量方向。特别是,我在解释Arrowhead函数的文档时遇到了问题,它说:

角度:箭头相对于x轴的逆时针角度,单位为度[0360];一个值或一个向量


但这需要我的未转换的价值观。这是否意味着他们是正确的?或者它们需要格式化吗?如何从[-180180]到[0360]?

只需像这样更改角度域:

   track_id       track_length frame          x         y         dx           dy steplength   direction
     <fctr>             <fctr> <dbl>      <dbl>     <dbl>      <dbl>        <dbl>      <dbl>       <dbl>
 1  Track 1 Track length:  464     0 -0.2779444 0.6532534  0.0000000  0.000000000  0.0000000   0.0000000
 2  Track 1 Track length:  464     1  0.9527568 1.6890017  1.2307012  1.035748375  1.6085398  40.0836991
 3  Track 1 Track length:  464     2  3.1617740 1.5406508  2.2090172 -0.148350899  2.2139930  -3.8420418
 4  Track 1 Track length:  464     3  3.4791213 1.1602548  0.3173472 -0.380396044  0.4953892 -50.1632825
 5  Track 1 Track length:  464     4  3.0130556 1.7207842 -0.4660657  0.560529394  0.7289790 129.7426481
 6  Track 1 Track length:  464     5  4.1270750 1.7163850  1.1140194 -0.004399235  1.1140281  -0.2262584
 7  Track 1 Track length:  464     6  3.5344773 2.2045875 -0.5925977  0.488202537  0.7677980 140.5171189
 8  Track 1 Track length:  464     7  1.8244100 2.3753219 -1.7100673  0.170734431  1.7185693 174.2984400
 9  Track 1 Track length:  464     8  3.2462738 1.7072696  1.4218637 -0.668052374  1.5709839 -25.1661450
10  Track 1 Track length:  464     9  2.0981822 2.1773816 -1.1480916  0.470112097  1.2406126 157.7322425
if (angle < 0)
    angle = angle + 360