I'm trying to figure out whether some vector angles I'm using are correctly calculated.
I have a simulated particle track with data like this:
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
The direction column is calculated like so:
direction = (180/pi)*(atan2(dy, dx)))
And this gives me an angle for the vector of every point in a [-180, 180] degree format. I checked with ggplot's arrow feature and the angles appear to be correct. So far so good.
Now, I want to plot the vector directions for every xy-bin using a combination of raster and shape packages. In particular, I'm having trouble with interpretation of the Arrowhead() function's documentation, which says:
angle: angle of arrowhead (anti-clockwise, relative to x-axis), in degrees [0,360]; either one value or a vector.
It takes my "unconverted" values though. Does that mean they're correct? Or do they need to be formatted? How do I go from [-180, 180] to [0, 360]?