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; }
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; }
GfVec3d GfRay::FindClosestPoint(const GfVec3d &point, double *rayDistance) const { GfLine l; double len = l.Set(_startPoint, _direction); double lrd; (void) l.FindClosestPoint(point, &lrd); if (lrd < 0.0) lrd = 0.0; if (rayDistance) *rayDistance = lrd / len; return l.GetPoint(lrd); }
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, <1, <2 ) ) 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, <1); } if ( p1 ) *p1 = cp1; if ( p2 ) *p2 = cp2; if ( t1 ) *t1 = lt1; if ( t2 ) *t2 = lt2; return true; }