Yes, 30.0 is the width and 20.0 is the height (as in the examples in the first post). I think of the ray as being a particle starting at the red point, moving at constant velocity so that at time 1 it is at the green point. I use vertical_intersection_time and horizontal_intersection_time to see when that particle would hit the edges of the map. Whichever one happens first is where the black dot will be.
std::min does what you expect: Return the minimum of two values. I don't know how you say that in Java.