# \[ANN\] AngleBetweenVectors

**URL:** <https://discourse.julialang.org/t/ann-anglebetweenvectors/12710>\
**Category:** Community\
**Tags:** package, announcement\
**Created:** [July 28, 2018, 7:46pm UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710 "2018-07-28T19:46:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 28, 2018, 7:46pm UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/1 "2018-07-28T19:46:40Z")

</div>

[AngleBetweenVectors.jl](https://github.com/JeffreySarnoff/AngleBetweenVectors.jl)

`angle(point1, point2)` determines the angle between point1 and point2. The smallest angle is returned and `π` obtains when the points are oppositely directed: `[(1,0), (-1,0)]`.  
So, `0 <= angle(p1, p2) <= pi`. It does this with more accuracy than the usual way.

`angle(p1, p2)` expects `p1`, `p2` to be points in a 2D, 3D … ManyD space, with Cartesian coordinates. To use any given point representation, define its Tuple constructor (unless one already exists). `Vectors`, `NamedTuples`, `SVectors` already have that.

This package is posted by request. The method is work of [Professor Kahan](https://people.eecs.berkeley.edu/%7Ewkahan/MathH110/Cross.pdf) (pg 15).

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [July 28, 2018, 10:17pm UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/2 "2018-07-28T22:17:14Z")

</div>

Thanks for posting this!

I will consider how well it fits in DynamicalBilliards.jl! We are doing this computation literally every step in the hottest loops.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 29, 2018, 12:15am UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/3 "2018-07-29T00:15:06Z")

</div>

I am glad you said something!

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 30, 2018, 2:47am UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/4 "2018-07-30T02:47:18Z")

</div>

[improved] Now there are two exports, `angle` and `fastangle`. Both are accurate. `angle` is more accurate; `fastangle` is more performant (I see it 30% faster). `angle` should always be used where the abs() of some coordinates may be outside of 2^±20. Tagged v0.2.0.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [July 30, 2018, 4:42am UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/5 "2018-07-30T04:42:32Z")

</div>

My understanding of [https://semver.org](https://semver.org) is that you start from version 0.1.0 and each new feature increments minor version, thus this package should already be at 0.2.0 version if you would like to follow semantic versioning.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [July 30, 2018, 6:03am UTC](https://discourse.julialang.org/t/ann-anglebetweenvectors/12710/6 "2018-07-30T06:03:18Z")

</div>

Sure – see above.
