How to efficiently calculate points of intersection of a straight line and a contour? Ex. 
I have an image, let's say 100x100 pixels with some shape on it. And a set of straight lines that are passing through origin located at some point of image, for example origin located at point (50, 50). Number of lines determined by step - angle. If step = 15 degrees, then we have 180 / 15 lines. I want to determine points of interesection in efficient way, but all that I came up for now is printing a line on matrix and check for non-zero elements if they overlap non-zero elements of a shape(and check for diagonal connectivity).
Calculate the straight lines angles with respect to the x-axis

Calculate the angles of each and every point on the contour

Search for points on the contour with same angles as the lines with respect to the origin. 

These are the points of line-contour crossing.