analytics

Wednesday, March 5, 2014

Direction of vector function

So I wanted a function that goes from 0 to 2*pi and corresponds to the direction a vector is pointing on the plane. It was hard to do the first few ways I thought of with complex exponentials and arcsins and things of that nature, so I settled for a quadratic approximation. I picked the 9 integer points corresponding to the -1..1 x and y values of the vector and interpolated through what each pair should return. This is what I came up with:

So you have a vector: And you scale it by magnitude:
Then you plug these two components in the first function I listed as x and y:
And 1.211*pi looks pretty reasonable for these points.

No comments:

Post a Comment