How to find the equation of a line inside a circle given the center point of the line?

900 Views Asked by At

I have a circle with center (0,0) and radius 1. I have calculated a random point inside a circle by generating a random angle $a=random()\cdot 2\pi $ and a random distance smaller than or equal to the radius $b=random()\cdot r$. The center of the line is $(cos(a)\cdot b,sin(a)\cdot b)$. The line has to be inside the circle like this: enter image description here

Knowing this information how can I calculate the equation of the line in the most efficient way for a computer? Thanks.

The random function generates a random Real Number between 0 and 1.

3

There are 3 best solutions below

1
On BEST ANSWER

In polar coordinates,

$$\rho\cos(\theta-a)=b,$$

hence $$x\cos a+y\sin a=b.$$

0
On

The point is at angle $a$, so the line must be at angle $a+\frac\pi2$. (Do you see why?) Provided that $a$ is not a multiple of $\frac\pi2$, one can then write

$$ (y-b\sin a) = -\frac{x-b\cos a}{\tan a} $$

Simple algebra will then provide this equation in whatever form you desire. You can complete the analysis by examining the cases where $a$ is a multiple of $\frac\pi2$ (though these occur with probability $0$).

0
On

you can just do this with basic coordinate geometry. To find the line equation you need the slope and a point. Fortunately, the point is given. You can simply find the slope for the line since the product of two perpendicular lines' slope is -1.