I ' msorryifthisquestionseemsareallybasic,buticannotfindagoodansweronlineyet。
I ' malittleconfusedwithvectorsandhowtousetheminmatlab.atthemomentihavethefollowingthreepairofcooordinates (:个人1,tthemome
nowiwanttocalculatetheanglebetween ' thevectorwhichgoesfromperson1to person2' and ' thevectorfromperson1to person1future '.ini hiswiththevectors,butiamnotsureiamactuallyusingtherightinputforeachvector。
sonowmyquestionishowcaniusethesecoordinates (andthedifferencebetweenthem ) tocalculatetheanglefromtheimage?
althoughstefanm ' ssolutionisaprettycommonsolutiontothis,itisactuallycomputationallyexpensive,but most importantly, incorrectwhenthevectorsaretinyand/ortheangleisnear0or--itcanactuallyresultinanglesthatareslightlynegative,orslightlyexexynegate
Thus,it gives a false sense of robustness。
I'd instead suggest
theta=ACOS(min(1,max(-1,a ) a(a(: ).' *b ) : )/FZDBM(a )/FZDBM(a ) ) ) ) ) )
More robust,more correct,over 10 faster when run in a loop,andunderstandablebysdwdwithoutdocumentation,becauseitststillagresmes