2010年8月20日星期五

Bug Series - angle between two vectors

float dot = dot(v0, v1);
float radian = acos(dot);

more safe:
dot = Max(-1, Min(dot(v0, v1), 1); // make sure the dot is [-1, 1].
radian = acos(dot);

https://docs.google.com/document/pub?id=1KyKbHUXfrXh-7L0g4cP-l2QcqVDsmYPTyBJXjGAtXhA

没有评论:

发表评论