# Bisection line of a angle

Dear all,

I have two lines that mean four points(x,y) on picturebox.

i have allready find out then point (x,y) of intersection between them.

Now i want to determine the angle between them and then want draw a line which should pass though the intersection point and should be bisect this angle. pl help me out..

thanks

nikelsh
LVL 1
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Founder, InitQubeCommented:
Let (x1,y1) and (x2,y2) be the two points of the first line.
Get the distance between the two.
Now make a horizontal line passing from the (x1,y1) & drop a perpendicular from (x2,y2) on it.

By this you get the two distances, (x1,y1) - (x2,y2)
and (x1,y1) - (xc,yc) where (xc,yc) is the coordinate of the point that you get by intersection of the perpendicular and the horizontal line.

as we know that cosine(x) = distance (x1,y1) - (xc,yc) / distance (x1,y1) - (x2,y2) in this case and thus you could easily get the angle between horizontal and the line.

Similiarly, perform same operation on another line as well . Add the two and you get the actual angle between the two lines.

Now you could find the half of that angle and draw a line at a given angle.

Bit confusing but i hope you get it.

0
Commented:
I',m not sure my logic is right

Let (x1,y1) and (x2,y2) be the two points of the first line.
Let (x3,y3) and (x4,y4) be the two points of the second line.
Let (x0,y0) be the intersection between them

slope for the intercept line

m = (m1 + m2)/2
m = {[(y2-y1)/(x2-x1)] + [(y4-y3)/(x4-x3)]} / 2

since y = mx + b

b = y0 - mX0

and you will get the line equation as

y = mx + (y0 - mX0)

where m= {[(y2-y1)/(x2-x1)] + [(y4-y3)/(x4-x3)]} / 2

0
Commented:
Of course the second inteception line will be

ms * m = -1

and you will get the slope of the second line (ms)

and use the above to find the second equation
0
Author Commented:
hi EDDYKT,

your solution doe'nt work in case m =(m1+m2)/2 comes out zero as well as in m1 or m2 is zero.

ashutosh9910  your solution i couldn't understand what you want to say. if i want to determine only angle between them then i can use vector calculation but here i want to draw a line which should pass thought intersection as well as should bisect this two lines.

waiting for ans

nikelsh
0
Commented:
>>your solution doe'nt work in case m =(m1+m2)/2 comes out zero as well as in m1 or m2 is zero.

the both lines are parallel to x-axis and should has no intercept pt

Am i missing somehting?

in my case

m1 = (y2-y1)/(x2-x1)
m2 = (y4-y3)/(x4-x3)
0
Commented:
By the way, the way I do is general case. If you say one slope is 0 (x-axis), the other one must be y-axis which is infinite slope. In your code, you have to take a special case for this
0
Author Commented:
Hi EDDYKT,

Thanks for yur efforts.... but my problem not solved yet. i have tryied your solution but in all cases i am not getting right results.Now i want to give you my whole problem might be then it's easier to understand.

i am trying to give user to draw pipes, i.e means two parallel lines and a center line when user click and drag the mouse. which i have completed and it's happeing. After that user can set dia1 and dia2 of selected pipe in picturebox. Now i want to give user facility to select two pipes in picturebox and then click a button "Connect", and my works start in background  in which i have to extend or trim center lines as well as outer dia lins of two pipes. I have completed connection of center lines but for outer lines connection i am getting problem. So i thought about above solution, in which i would determine the bisection line eq. and then try to find out intersection with outer dia pipes. But i am not getting desired results. I thing Atn function of vb not producing desired results.

1. center points quardinets i.e.  x1,y1 and x2, y2 to each pipes
2. outer lines quardinates i.e.  xx1,yy1 and xx2,yy2 and xxx1,yyy1 and xxx2,yyy2.

i have same types of above information two objects

Now i want to determine  xc,yc and xu,yu and xv,yv all three cross-section so that i could join them. xc,yc i had determine already..

could you help me to find out this.......

nikelsh

0
Commented:
see me your code and see what's wrong
0
Author Commented:
it' ans is

Dim a As Single
Dim b As Single
Dim ang As Single
Dim M_angle As Single
Dim IsVertical As Boolean
Dim dxx1 As Single
Dim dxx2 As Single
Dim dyy1 As Single
Dim dyy2 As Single
'------------------------------------------------------------------
a = angle_Lines(obj_1, X1, Y1)
b = angle_Lines(obj_2, X1, Y1)
ang = (a + b) / 2
If ang < 90 Then
ang = -ang
ElseIf ang < 180 Then
ang = 180 - ang
ElseIf ang < 270 Then
ang = -(ang - 180)
Else
ang = ang - 180
End If

'------------------------------------------------------------------
' ' Now we have X,Y and m so we have to determine only C

If IsVertical Then
X2 = X1
Y2 = Y1 + 10
Else
C = Y1 - M * X1
' assume x= x-5
X2 = X1 + 10
Y2 = M * X2 + C
End If

Private Function angle_Lines(obj As vbdObject, x As Single, y As Single) As Single

Dim dx As Double
Dim DY As Double
Dim temp As Single
Dim a_mod As Single

If obj.x(1) = x Then
dx = obj.x(2) - x
Else
dx = obj.x(1) - x
End If
If obj.y(1) = y Then
DY = y - obj.y(2)
Else
DY = y - obj.y(1)
End If

If dx > 0 And DY = 0 Then
temp = 0
ElseIf dx > 0 And DY > 0 Then
temp = Atn(Abs(DY / dx))
ElseIf dx = 0 And DY > 0 Then
temp = PI / 2
ElseIf dx < 0 And DY > 0 Then
temp = PI - Atn(Abs(DY / dx))
ElseIf dx < 0 And DY = 0 Then
temp = PI
ElseIf dx < 0 And DY < 0 Then
temp = PI + Atn(Abs(DY / dx))
ElseIf dx = 0 And DY < 0 Then
temp = (3 / 2) * PI
ElseIf dx > 0 And DY < 0 Then
temp = 2 * PI - Atn(Abs(DY / dx))
End If
angle_Lines = Degrees(temp)

End Function

thanks to everyone who supported me....

nikelsh
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.