> Can somebody tell me a method to draw a perpendicular
> (formula) in order to find the points of tangency of
> two circles of same radii
I don't think you have given enough information. How is the line specified to which you want to draw a perpendicular How is the point specified from which you want to draw the perpendicular?
I have two circles.....i know the center's and radius of both of them....I need to draw a line tangent to the circles.....I know that the length of the line from two centers will be the same as the tangent line and their slopes are also equal...with this information i need draw a perpendicular in order to find the points of tangency.....but what is the method to draw the perpendicular?(mathematically or progamatically) or is there another method to find the points of tangency?
> I have two circles.....i know the center's and radius
> of both of them....I need to draw a line tangent to
> the circles.....I know that the length of the line
> from two centers will be the same as the tangent line
> and their slopes are also equal...with this
> information i need draw a perpendicular in order to
> find the points of tangency.....but what is the
> method to draw the perpendicular?(mathematically
> or progamatically) or is there another method to find
> the points of tangency?
You have the two points, so you know the slope, m, of the line: f(x) -> m*x + cthen the function gg(x) -> (-1/m)*x + crepresents the line perpendicular to f.
If you want to draw pictures learn about vectors.
You have two points, the centers of your circles (which are of the same radius R)
(x1,y1) & (x2,y2)
the x and y differences are
dx = x2-x1
dy = y2-y1
this gives you a vector (dx,dy) that lies along the line segment
It is probably not a unitl vector (its lenght is not necessarily one) so we make it a unit vector by computing its length
L = sqrt(dx*dx + dy*dy)
and now (dx/L,dy/L) is a unit vector so lets change dx and dy
dx = dx/L
dy = dy/L
and now (dx,dy) is unit vector
perpendicular vectors are negative recriprocals so
(-dy, dx) is a vector perpendicular to (dx,dy) and so is (dy,-dx). one of those vectors points to one side of the circle the other points to the other side of the circle (There are two directions in which you can displace the center line so that it is becomes a tangent line.
Also you want your translation scaled by the radius of the circle so you multiply by R So doing both the perpendicular transformation and the scaling in a single step to create the translation vector you get
tx = -R*dy
ty = R*dx
Finally you add the displacement vector to your original points to shove the line over in a perpendicular
newx1 = x1 + tx
newy1 = y1 + ty
newx2 = x2 + tx
newy2 = y2 + ty
That will be one of the tangent line segments, the other one will be obtained by using the negative of the translation vector (just subtract the tx & ty instead of adding)