I have declared a circle on a 9×9 matrix with radius = 1, and I want to draw line on it according to the parameters.
Here is the Matrix

And here is the parameters in order to find beginning and end points of the line which is drawn in red.

h1 and h2 are the brightness values of the two regions which are seperated with red line and you don’t have to consider it.
In other words pixel 1 is (3,1), 2 is (4,1) etc so the origin is (5,5) on x,y axis. By the way, I know the angle and p.
What would be your suggestions in order to obtain the beginning and end pixels or coordinates of this red line in order to draw it with drawline function?
Thanks in advance
P will bisect the red line. Distance between the center and end of red line is the radius of the circle which you know. Now calculate the length of the red line which will be 2( square root of sum of squares radius and p).
Calculate the relation between x and y from the equation which you have in terms of p and alpha.
Calculate the equation of circle in terms of radius and origin(you have both).
Solve the line’s equation and circle’s equation. As a solution you will get the two points of interaction between circle and line.