Geometry Problems C++

The Conqueror

Elevating Humanity
I was reading this tutorial Algorithm Tutorials
but I couldn't understand this piece of code. (Line-Point distance). Could someone explain this in a simpler way?

Code:
    //Compute the distance from AB to C
    //if isSegment is true, AB is a segment, not a line.
    double linePointDist(int[] A, int[] B, int[] C, boolean isSegment){
        double dist = cross(A,B,C) / distance(A,B);
        if(isSegment){
            int dot1 = dot(A,B,C);
            if(dot1 > 0)return distance(B,C);
            int dot2 = dot(B,A,C);
            if(dot2 > 0)return distance(A,C);
        }
        return abs(dist);
    }
 
This will help: Distance from a point to a line - Wikipedia, the free encyclopedia

It's basically calculating the minimum distance of point C from the line segment AB.
 
Top Bottom