I have two 2D spaces which are related one to other by a transformation matrix - 3*3 homography matrix for homogeneous coordinates: The first space is "map" and the second one is "camera view" (of camera that is flying above the map in unknown position). Both spaces are restricted either by map boundaries or size of the camera view (both rectangles). I have defined both in camera view and in map some polygons.
I need to display polygons from camera view in map, and vice versa.
Thing gets complicated when a line of a polygon in camera view passes horizon of the ground, and it will get projected to map incorrectly, as a point on the line that lies on the horizon is projected to infinity in map space. The same problem happens if a line of a polygon in the map space crosses the plane that is parallel to camera's projection plane passing through camera's origin.
Therefore, I need to deploy clipping of polygons before the transformation. However, all the literature I found on the topic deals with 3D space and known camera position.
Is there a way to clip a 2D line for 2D projection described by perspective 3*3 homography matrix (ergo, translation, rotation, projection, in homogeneous coordinates)? Is there a way to do this for general 3*3 homography matrix?