void SphereVolume::getBounds(Pnt3f &min, Pnt3f &max) const
{
    min.setValues(_center[0] - _radius,
                  _center[1] - _radius,
                  _center[2] - _radius);
    max.setValues(_center[0] + _radius,
                  _center[1] + _radius,
                  _center[2] + _radius);
}
Example #2
0
void VRMouse::multFull(Matrix _matrix, const Pnt3f &pntIn, Pnt3f  &pntOut) {
    float w = _matrix[0][3] * pntIn[0] +
                  _matrix[1][3] * pntIn[1] +
                  _matrix[2][3] * pntIn[2] +
                  _matrix[3][3];

    /*if (w <1) {
        fstream file("dump.txt", fstream::out | fstream::app);
        file << w << endl;
        file.close();
    }*/

    if(w == TypeTraits<float>::getZeroElement())
    {
        cout << "\nWARNING: w = " << _matrix[0][3] * pntIn[0] << " " << _matrix[1][3] * pntIn[1] << " " << _matrix[2][3] * pntIn[2];


        pntOut.setValues(
            (_matrix[0][0] * pntIn[0] +
             _matrix[1][0] * pntIn[1] +
             _matrix[2][0] * pntIn[2] +
             _matrix[3][0]             ),
            (_matrix[0][1] * pntIn[0] +
             _matrix[1][1] * pntIn[1] +
             _matrix[2][1] * pntIn[2] +
             _matrix[3][1]             ),
            (_matrix[0][2] * pntIn[0] +
             _matrix[1][2] * pntIn[1] +
             _matrix[2][2] * pntIn[2] +
             _matrix[3][2]             ) );
    }
    else
    {
        w = TypeTraits<float>::getOneElement() / w;

        pntOut.setValues(
            (_matrix[0][0] * pntIn[0] +
             _matrix[1][0] * pntIn[1] +
             _matrix[2][0] * pntIn[2] +
             _matrix[3][0]             ) * w,
            (_matrix[0][1] * pntIn[0] +
             _matrix[1][1] * pntIn[1] +
             _matrix[2][1] * pntIn[2] +
             _matrix[3][1]             ) * w,
            (_matrix[0][2] * pntIn[0] +
             _matrix[1][2] * pntIn[1] +
             _matrix[2][2] * pntIn[2] +
             _matrix[3][2]             ) * w );
    }
}
Pnt3f randomOpenPosition(const Pnt3f& Min,
                         const Pnt3f& Max,
                         OctreePtr TheOctree)
{
    Pnt3f Result;
    do
    {
        Result.setValues(RandomPoolManager::getRandomReal32(Min.x(),Max.x()),
                         RandomPoolManager::getRandomReal32(Min.y(),Max.y()),
                         RandomPoolManager::getRandomReal32(Min.z(),Max.z()));
    }while(!TheOctree->getNodeThatContains(Result)->isEmpty());

    return Result;
}