Filling a 2D histogram with lines

Hello All,

I am wondering if there is an easy way to do this:
I want to create a 2D histogram and populate it with lines.
Each of my data point are the ends of a line. x1,y1,x2,y2.
I would like to increment all the bins in the 2D histogram along the line defined by (x1,y1) and (x2,y2).



A simple way is to generate a uniform random point (x,y) along the line and then fill the histogram. So, you generate a x value between x1 and x2 ( double x = gRandom->Uniform(x1,x2) ) and then you find the y value using the line equation: y = y1 + (y2-y1)/(x2-x1) * (x -x1) and then you fill the histogram with th eobtained x,y values.

Best Regards