Convex Hull Jarvis Algorithm

How do we calculate orientation using the code below in convex hull algorithm?

int orientation(Point p, Point q, Point r)
{
int val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); //I do not understand this line

if (val == 0) return 0; 
return (val > 0)? 1: 2;  

}