12 #ifndef VERDICT_VECTOR
13 #define VERDICT_VECTOR
22 double answer = vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2];
29 double x = sqrt( vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] );
37 inline double*
cross_product(
double vec1[],
double vec2[],
double answer[] )
39 answer[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
40 answer[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
41 answer[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
48 return sqrt( vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] );
54 return ( vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] );
60 double cosAngle, angleRad;
61 double length1 =
length( vec1 );
62 double length2 =
length( vec2 );
63 assert( ( length1 > 0.0 && length2 > 0.0 ) );
65 cosAngle =
dot_product( vec1, vec2 ) / ( length1 * length2 );
67 if( ( cosAngle > 1.0 ) && ( cosAngle < 1.0001 ) )
71 else if( cosAngle < -1.0 && cosAngle > -1.0001 )
77 assert( cosAngle < 1.0001 && cosAngle > -1.0001 );
80 angleRad = acos( cosAngle );