lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> To calculate the angle beteween the two vectors, you sould do:
>
> math.atan2(b[2],b[1]) - math.atan2(a[2],a[1])
>
>

Not that simple.  That could give anything between ± 2 pi, whereas angle should
be between ± pi.  Instead:

math.atan2 (a[1]*b[2]-a[2]*b[1],a[1]*b[1]+a[2]*b[2])