Vector Angle

100 views
Skip to first unread message

M@

unread,
Sep 6, 2010, 4:09:19 AM9/6/10
to tinspire
I couldn't find a function to return the angle of a two dimentional
vector [x,y]
There is always the ►Polar command but I wanted a function that ONLY
returns the angle for use in other calculations.

I created this solution:

Define LibPub ang(x)=
Func
©Retuns angle of [i,j] vector
Local m
m:=mat►list(x)
Return tanˉ¹(m[2]/m[1])
EndFunc


Placed in the MyLib folder under vector I can now call the function
with
vector\ang([x,y])
from anywhere. Note the backslash can be found with Shift, Divide
buttons on TI-nSpire CAS

Wayne

unread,
Sep 6, 2010, 8:01:19 PM9/6/10
to tinspire
If the vector is called v, then the built-in function that returns the
angle is R▶Pθ(v[1,1],v[1,2]). To avoid using the matrix
representation of the vector you could also use R▶Pθ(mat▶list(v)
[1],mat▶list(v)[2]). Either method is cumbersome and this has always
seemed like a good place for some improvements to be made.

Wayne
Reply all
Reply to author
Forward
0 new messages