function mapPointToPath (out, path, point) {
    let d, minDistance

    // loop over all segments, find the one nearest to the given point
    for (let i = 1; i < path.pointCount; i++) {
        pointToSegmentDistance(tmpSegDistance, point, path.points[i-1], path.points[i])
        d = tmpSegDistance.distance
        if ((minDistance === undefined) || d < minDistance) {
            minDistance = d
            vec2.copy(out.onPath, tmpSegDistance.chosen) // set the point on the path

            vec2.subtract(out.tangent, path.points[i], path.points[i-1])
            vec2.normalize(out.tangent, out.tangent)
        }
    }

    // measure how far original point is outside the Pathway's "tube"
    out.outside = vec2.distance(out.onPath, point) - path.radius

    return out
}
// that a negative distance indicates A is inside the Pathway.
that a negative distance indicates A is inside the Pathway.
that a negative distance indicates A is inside the Pathway .
function mapPointToPath (out, path, point) {
    let d, minDistance
    for (let i = 1; i < path.pointCount; i++) {
        pointToSegmentDistance(tmpSegDistance, point, path.points[i-1], path.points[i])
        d = tmpSegDistance.distance
        if ((minDistance === undefined) || d < minDistance) {
            minDistance = d
            vec2.copy(out.onPath, tmpSegDistance.chosen) 
            vec2.subtract(out.tangent, path.points[i], path.points[i-1])
            vec2.normalize(out.tangent, out.tangent)
        }
    }
    out.outside = vec2.distance(out.onPath, point) - path.radius
    return out
}
function mapPointToPath ( out , path , point ) { let d , minDistance for ( let i = 1 ; i < path . pointCount ; i ++ ) { pointToSegmentDistance ( tmpSegDistance , point , path . points [ i - 1 ] , path . points [ i ] ) d = tmpSegDistance . distance if ( ( minDistance === undefined ) || d < minDistance ) { minDistance = d vec2 . copy ( out . onPath , tmpSegDistance . chosen ) vec2 . subtract ( out . tangent , path . points [ i ] , path . points [ i - 1 ] ) vec2 . normalize ( out . tangent , out . tangent ) } } out . outside = vec2 . distance ( out . onPath , point ) - path . radius return out }
that a negative distance indicates A is inside the Pathway.
that a negative distance indicates A is inside the Pathway .
// loop over all segments, find the one nearest to the given point // set the point on the path // measure how far original point is outside the Pathway's "tube"