//--------------------------------------------------------- double CSG_Vector::Get_Angle(const CSG_Vector &Vector) const { if( Get_N() > Vector.Get_N() ) { return( Vector.Get_Angle(*this) ); } int i; double A, B, z, *Z = Get_Data(); if( (A = Get_Length()) > 0.0 && (B = Vector.Get_Length()) > 0.0 ) { for(i=0, z=0.0; i<Get_N(); i++) { z += Vector[i] * Z[i]; } for(i=Get_N(); i<Vector.Get_N(); i++) { z += Vector[i]; } return( acos(z / (A * B)) ); } return( 0.0 ); }
//--------------------------------------------------------- std::pair<double,double> minmax(CSG_Vector v) { double min = v[0]; double max = v[0]; for (int i = 0; i < v.Get_Length(); i++) { if (v[i] > v[0]) { max = v[i]; } else if (v[i] < v[0]) { min = v[i]; } } return std::make_pair(min, max); }