Пример #1
0
double GeometryTools::getAngle(const cvf::Vec3d& positiveNormalAxis, const cvf::Vec3d& v1, const cvf::Vec3d& v2)
{
    bool isOk = false;
    cvf::Vec3d v1N = v1.getNormalized(&isOk);
    if (!isOk) return 0;
    cvf::Vec3d v2N = v2.getNormalized();
    if (!isOk) return 0;

    double cosAng = v1N * v2N;
    // Guard acos against out-of-domain input
    if (cosAng <= -1.0) 
    {
        cosAng = -1.0; 
    }
    else if (cosAng >= 1.0)
    {
        cosAng = 1.0; 
    }
    double angle = acos(cosAng);

    cvf::Vec3d crossProd = v1N ^ v2N;
    double sign = positiveNormalAxis * crossProd;
    if (sign < 0)
    {
        angle = 2*MY_PI - angle;
    }
    return angle;
}
Пример #2
0
double GeometryTools::getAngle(const cvf::Vec3d& v1, const cvf::Vec3d& v2)
{
    bool isOk = false;
    cvf::Vec3d v1N = v1.getNormalized(&isOk);
    if (!isOk) return 0;
    cvf::Vec3d v2N = v2.getNormalized();
    if (!isOk) return 0;

    double cosAng = v1N * v2N;
    // Guard acos against out-of-domain input
    if (cosAng <= -1.0) 
    {
        cosAng = -1.0; 
    }
    else if (cosAng >= 1.0)
    {
        cosAng = 1.0; 
    }
    double angle = acos(cosAng);

    return angle;
}
Пример #3
0
//--------------------------------------------------------------------------------------------------
/// Set the axes
/// 
/// The specified axes will be normalized
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setAxes(const cvf::Vec3d& axisU, const cvf::Vec3d& axisV)
{
    m_axisU = axisU.getNormalized();
    m_axisV = axisV.getNormalized();
}