From: <bjo...@ya...> - 2005-02-28 11:18:23
|
Hello, since I needed the getClosestPoints method of Line I implemented it using some class notes. I strongly suppose it is correct, and a few tests didn't suggest otherwise. Maybe you could commit it to CVS? Björn OSGLine.cpp: bool Line::getClosestPoints(const Line &line2, Pnt3f &ptOnThis, Pnt3f &ptOnLine2) const { // Assumes that _dir and line2._dir are valid and normalized Vec3f normal=_dir.cross(line2._dir); if(normal.isZero()) return false; // Lines are parallel Vec3f p0p1=line2._pos-_pos; Real32 lengthSqr=normal.squareLength(); Real32 s=p0p1.cross(line2._dir).dot(normal) / lengthSqr; Real32 t=p0p1.cross( _dir).dot(normal) / lengthSqr; ptOnThis = _pos + s * _dir; ptOnLine2=line2._pos + t * line2._dir; return true; } ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |