Exemplo n.º 1
0
unsigned
GeoMath::intersectLineWithPlane(const osg::Vec3d& p0,
                                const osg::Vec3d& p1,
                                const osg::Plane& plane,
                                osg::Vec3d&       out_p)
{
    osg::Vec3d V = p1-p0;
    V.normalize();
    double denom = plane.dotProductNormal(V);

    // if N*V == 0, line is parallel to the plane
    if ( osg::equivalent(denom, 0.0) )
    {
        // if p0 lies on the plane, line is coincident with plane
        // and intersections are infinite
        if ( osg::equivalent(plane.distance(p0), 0.0) )
        {
            out_p = p0;
            return 2;
        }
        else
        {
            // line does not intersect plane.
            return 0;
        }
    }
    else
    {
        // one intersection:
        double t = -(plane.dotProductNormal(p0) + plane[3])/denom;
        out_p = p0 + V*t;
        return 1;
    }
}
Exemplo n.º 2
0
bool
Horizon::getPlane(osg::Plane& out_plane) const
{
    // calculate scaled distance from center to viewer:
    if ( _valid == false || _VCmag2 == 0.0 )
        return false;

    double PCmag;
    if ( _VCmag > 0.0 )
    {
        // eyepoint is above ellipsoid? Calculate scaled distance from center to horizon plane
        PCmag = 1.0/_VCmag;
    }
    else
    {
        // eyepoint is below the ellipsoid? plane passes through the eyepoint.
        PCmag = _VCmag;
    }

    osg::Vec3d pcWorld = osg::componentMultiply(_eyeUnit*PCmag, _scaleInv);
    double dist = pcWorld.length();

    // compute a new clip plane:
    out_plane.set(_eyeUnit, -dist);
    return true;
}
        PolytopeIntersection(unsigned int index, const CandList_t& cands, const osg::Plane &referencePlane) :
            _maxDistance(-1.0), _index(index-1), _numPoints(0)
        {
            Vec3_type center;
            for (CandList_t::const_iterator it=cands.begin(); it!=cands.end(); ++it)
            {
                PlaneMask mask = it->first;
                if (mask==0) continue;

                _points[_numPoints++] = it->second;
                center += it->second;
                value_type distance = referencePlane.distance(it->second);
                if (distance > _maxDistance) _maxDistance = distance;
                if (_numPoints==MaxNumIntesections) break;
            }
            center /= value_type(_numPoints);
            _distance = referencePlane.distance( center );
        }
Exemplo n.º 4
0
bool
Horizon::getPlane(osg::Plane& out_plane) const
{
    // calculate scaled distance from center to viewer:
    double magVC = _cv.length();
    if ( magVC == 0.0 )
        return false;

    // calculate scaled distance from center to horizon plane:
    double magPC = 1.0/magVC;

    osg::Vec3d normal = _cv;
    normal.normalize();

    osg::Vec3d pcWorld = osg::componentMultiply(normal*magPC, _scaleInv);
    double dist = pcWorld.length();

    // compute a new clip plane:
    out_plane.set(normal, -dist);
    return true;
}
Exemplo n.º 5
0
static boost::python::tuple intersectInfinite_6a2ff5d33bbc8765b45604a87b32cb50( ::OSG::Plane const & inst, ::OSG::Line const & l ){
    OSG::Point<float, 3u> intersection2;
    bool result = inst.intersectInfinite(l, intersection2);
    return bp::make_tuple( result, intersection2 );
}
Exemplo n.º 6
0
static boost::python::tuple intersectInfinite_ecf75f482cf72f5bb06e2f48caedf6ea( ::OSG::Plane const & inst, ::OSG::Line const & l ){
    float t2;
    bool result = inst.intersectInfinite(l, t2);
    return bp::make_tuple( result, t2 );
}
Exemplo n.º 7
0
static boost::python::tuple intersect_b2ddef634f93d137b320d331bba0a7e9( ::OSG::Plane const & inst, ::OSG::Line const & l ){
    float t2;
    bool result = inst.intersect(l, t2);
    return bp::make_tuple( result, t2 );
}
Exemplo n.º 8
0
static boost::python::tuple intersect_422b4819a67dd604f95a289c2a33664b( ::OSG::Plane const & inst, ::OSG::Line const & l ){
    OSG::Point<float, 3u> intersection2;
    bool result = inst.intersect(l, intersection2);
    return bp::make_tuple( result, intersection2 );
}
Exemplo n.º 9
0
static boost::python::tuple intersect_1ae0b3229395ec6fea05959d6e1004c7( ::OSG::Plane const & inst, ::OSG::Plane const & pl ){
    OSG::Line intersection2;
    bool result = inst.intersect(pl, intersection2);
    return bp::make_tuple( result, intersection2 );
}
double distanceLineOnPlane(const osg::Vec3d& src, const osg::Vec3d& dst, const osg::Plane& plane)
{
  // can be optimized -> dst-src is a axis aligned vector
  return (-plane[3] - plane.dotProductNormal(src))/plane.dotProductNormal(dst - src);
}