00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00024
00025 #ifndef BTK_MATH_VECTOR_MATH_HPP
00026 #define BTK_MATH_VECTOR_MATH_HPP
00027
00028 #include <cmath>
00029
00030 #include <btk/core/math/btk_vector.hpp>
00031
00032 namespace BTK {
00033 namespace MATH {
00034
00036
00037
00040 inline
00041 BTKVector &
00042 normalize(BTKVector & v)
00043 {
00044 v /= norm_2(v);
00045 return v;
00046 }
00047
00053 inline double length(BTKVector const & v) { return norm_2(v); }
00054
00056 inline
00057 BTKVector
00058 cross(BTKVector const & lhs,
00059 BTKVector const & rhs)
00060 {
00061 BTKVector temp;
00062
00063 temp[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
00064 temp[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
00065 temp[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0];
00066
00067 return temp;
00068 }
00069
00072 BTKVector
00073 project(BTKVector const & a,
00074 BTKVector const & b);
00075
00078 BTKVector
00079 project_normal(BTKVector const & a,
00080 BTKVector const & b);
00081
00083 inline
00084 double
00085 cosine_vector_angle(BTKVector const & v1,
00086 BTKVector const & v2)
00087 {
00088 return (prec_inner_prod(v1,v2) / (norm_2(v1) * norm_2(v2)));
00089 }
00090
00092 inline
00093 double
00094 vector_angle(BTKVector const & v1,
00095 BTKVector const & v2)
00096 {
00097 return acos(cosine_vector_angle(v1,v2));
00098 }
00099
00105 double
00106 vector_dihedral(BTKVector const & v1,
00107 BTKVector const & v2,
00108 BTKVector const & v3);
00109
00111
00112 }
00113 }
00114
00115 #endif // BTK_VECTOR_MATH_H