lib/toxi/geom/Line3D.js
function(p) {
        var v = this.b.sub(this.a);
        var t = p.sub(this.a).dot(v) / v.magSquared();
        // Check to see if t is beyond the extents of the line segment
        if (t < 0.0) {
            return this.a.copy();
        } else if (t > 1.0) {
            return this.b.copy();
        }
        // Return the point between 'a' and 'b'
        return this.a.add(v.scaleSelf(t));
    }
function(p) {
        var v = this.b.sub(this.a);
        var t = p.sub(this.a).dot(v) / v.magSquared();
        // Check to see if t is beyond the extents of the line segment
        if (t < 0.0) {
            return this.a.copy();
        } else if (t > 1.0) {
            return this.b.copy();
        }
        // Return the point between 'a' and 'b'
        return this.a.add(v.scaleSelf(t));
    }
function ( p ) { var v = this . b . sub ( this . a ) ; var t = p . sub ( this . a ) . dot ( v ) / v . magSquared ( ) ; // Check to see if t is beyond the extents of the line segment if ( t < 0.0 ) { return this . a . copy ( ) ; } else if ( t > 1.0 ) { return this . b . copy ( ) ; } // Return the point between 'a' and 'b' return this . a . add ( v . scaleSelf ( t ) ) ; }
Computes the closest point on this line to the given one.

@param p
point to check against
@return closest point on the line
Computes the closest point on this line to the given one .