draw line which is perpindicular to another line with a wanted length can anyone help me? I have a line $Ax+By+C=0$ (let's call it Line $1$); I want to draw a perpicidular line (Line $2$) from the center of line $1$ with a length of $10$.
 what I did is get the slope and intercept of line $1$ as well as the its middle point (point $m$).
and I used the length equation $L=\sqrt{(\text{line}\space 2\cdot x-m\cdot x)^2+(\text{line}\space 2\cdot y-m\cdot y)^2}$, but I dont get the right result.
Thanks in advance
Thanks guys for your support. here's what i did ( and yaay it works)
1-As i have the line equation (or points) i got dy and dx.
2- i got the normal vector to the line(-dy,dx) and (dy,-dx) let's call it NormalVec1 and NormalVec2.
3- i got the magnitude of NormalVec
4- i got the UNIT normalvector by dividing NormalVec by its Magnitude.
5- assume that i want a line with length L.
   so it gonna be L/2 on both sides.
6- assume that i want to draw this perpindicular line crosing the original line at its center point M.
7-so the perpindicular line's points are:
endpoint=(M.X+unitNormalVec1*L/2 ,M.X+unitNormalVec1*L/2) ; for normalVec1 is (-dy,dx)
startpoint=(M.X+unitNormalVec2*L/2 ,M.X+unitNormalVec2*L/2) ; for normalVec1 is (dy,-dx)
then you can draw a line segment from these points.
Thanks,
Your code calculates the length of half the existing line. There are many ways to solve your problem. Get start and end coords, sx, sy, ex, ey. Calculate the slope angle with angle=atan(dy/dx), where dx=ex-sx, dy=ey-sy. Add or subtract pi/2 to angle. Calculate midpoint with mx=(ex-sx)/2 and my=(ey-sy)/2. This is the start point of the perpendicular line. Get the end point with mex=mx+10*cos(angle), mey=my+10*sin(angle). Easy as pi/2. :)