How to understand distPointLine function in FastLineDetectorImpl

this function get the distance from point to line , i can not understand the calculate method it use.

double FastLineDetectorImpl::distPointLine(const Mat& p, Mat& l)
{
    double x = l.at<double>(0,0);
    double y = l.at<double>(1,0);
    double w = sqrt(x*x+y*y);

    l.at<double>(0,0) = x / w;
    l.at<double>(1,0) = y / w;
    l.at<double>(2,0) = l.at<double>(2,0) / w;

    return l.dot(p);
}