Exemplo n.º 1
0
bool 
GfFindClosestPoints( const GfLineSeg &seg1, const GfLineSeg &seg2,
		     GfVec3d *p1, GfVec3d *p2,
		     double *t1, double *t2 )
{
    GfVec3d cp1, cp2;
    double lt1, lt2;
    if ( !GfFindClosestPoints( seg1._line, seg2._line,  
			       &cp1, &cp2, &lt1, &lt2 ) )
	return false;

    lt1 = GfClamp( lt1 / seg1._length, 0, 1 );
    
    lt2 = GfClamp( lt2 / seg2._length, 0, 1 );

    if ( p1 )
	*p1 = seg1.GetPoint( lt1 );

    if ( p2 )
	*p2 = seg2.GetPoint( lt2 );

    if ( t1 )
	*t1 = lt1;

    if ( t2 )
	*t2 = lt2;

    return true;
}
Exemplo n.º 2
0
Arquivo: ray.cpp Projeto: JT-a/USD
bool
GfFindClosestPoints(const GfRay &ray, const GfLine &line,
		    GfVec3d *rayPoint,
		    GfVec3d *linePoint,
		    double *rayDistance,
		    double *lineDistance)
{
    GfLine l;
    double len = l.Set(ray._startPoint, ray._direction);

    GfVec3d rp, lp;
    double rd,ld;

    if (!GfFindClosestPoints(l, line, &rp, &lp, &rd, &ld))
	return false;

    if (rd < 0.0) rd = 0.0;

    if (rayPoint)
	*rayPoint = l.GetPoint(rd);

    if (linePoint)
	*linePoint = lp;

    if (rayDistance)
	*rayDistance = rd / len;

    if (lineDistance)
	*lineDistance = ld;

    return true;
}
Exemplo n.º 3
0
bool 
GfFindClosestPoints( const GfLine &line, const GfLineSeg &seg,
		     GfVec3d *p1, GfVec3d *p2,
		     double *t1, double *t2 )
{
    GfVec3d cp1, cp2;
    double lt1, lt2;
    if ( !GfFindClosestPoints( line, seg._line,  &cp1, &cp2, &lt1, &lt2 ) )
	return false;

    lt2 = GfClamp( lt2 / seg._length, 0, 1 );
    cp2 = seg.GetPoint( lt2 );

    // If we clamp the line segment, change the rayPoint to be 
    // the closest point on the ray to the clamped point.
    if (lt2 <= 0 || lt2 >= 1){
        cp1 = line.FindClosestPoint(cp2, &lt1);
    }

    if ( p1 )
	*p1 = cp1;

    if ( p2 )
        *p2 = cp2;

    if ( t1 )
	*t1 = lt1;

    if ( t2 )
	*t2 = lt2;

    return true;
}
Exemplo n.º 4
0
Arquivo: ray.cpp Projeto: JT-a/USD
bool 
GfFindClosestPoints(const GfRay &ray, const GfLineSeg &seg,
		    GfVec3d *rayPoint,
		    GfVec3d *segPoint,
		    double *rayDistance,
		    double *segDistance)
{
    GfLine l;
    double len = l.Set(ray._startPoint, ray._direction);

    GfVec3d rp, sp;
    double rd,sd;

    if (!GfFindClosestPoints(l, seg, &rp, &sp, &rd, &sd))
	return false;

    if (rd < 0.0) rd = 0.0;

    if (rayPoint)
	*rayPoint = l.GetPoint(rd);

    if (segPoint)
	*segPoint = sp;

    if (rayDistance)
	*rayDistance = rd / len;

    if (segDistance)
	*segDistance = sd;

    return true;
}