Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bisection line of a angle

Posted on 2004-11-02
11
Medium Priority
?
501 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:nikelsh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 12471956
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12472186
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12472252
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:nikelsh
ID: 12480024
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12482252
>>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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12482271
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
 
LVL 1

Author Comment

by:nikelsh
ID: 12489941
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.

what i had......

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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12492746
see me your code and see what's wrong
0
 
LVL 1

Accepted Solution

by:
nikelsh earned 0 total points
ID: 12816049
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

M = Tan(Rad(ang))
'------------------------------------------------------------------
    ' ' 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question