jeffreysarnoff / anglebetweenvectors.jl Goto Github PK
View Code? Open in Web Editor NEWAn accurate and stable calculation of the angle separating two vectors.
License: MIT License
An accurate and stable calculation of the angle separating two vectors.
License: MIT License
Hi, I noticed that angle
does not actually do as claimed in the docstrings:
help?> angle
...
If one of the points is at the origin, the result is zero.
...
Specifically:
julia> angle((0.0, 0.0), (1.0, 1.0))
NaN
Also, there is some inconsistent behaviour near the origin:
julia> angle((0.0, 0.001), (1.0, 1.0))
0.7853981633974483
julia> angle((0.001, 0.001), (1.0, 1.0))
1.5700924586837754e-16
julia> angle((0.0001, 0.001), (1.0, 1.0))
0.6857295109062864
julia> angle((0.0001, 0.0001), (1.0, 1.0))
1.5700924586837754e-16
I would expect all of the above to be approximately 0.7853981633974483
?
I am using [ec570357] AngleBetweenVectors v0.3.0
.
Maybe I am totally wrong but could this code be even better without divisions:
n1 = norm(point1)
n2 = norm(point2)
p1 = n2 * point1
p2 = n1 * point2
# p1 and p2 have now same magnitudes
y = p1 .- p2
x = p1 .+ p2
a = 2 * atan(norm(y) , norm(x)) # use atan2(Y,X) result already in [0,pi]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.