Results 1 to 4 of 4

Thread: Line Distance?

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409

    Line Distance?

    3x-4y-10=0
    6x-8y+5=0

    are two parallel lines. How to calculate the distance between them.

    The formula for calculating the distance between a line and a point is
    [code]
    point A(a,b)
    line p = Ax+By+C=0

    distance d = (|Aa+Bb+C|) / (squareroot(A^2+B^2)

    Hoe do i get a point from a line. I know it was very easy but i forgot it.

    Thanks!
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Lively Member
    Join Date
    May 2000
    Posts
    84
    your equations can also be represented as
    line 1: y = 3x/4 -10/4
    line 2: y = 6x/8 +5/8 = 3x/4 +5/8

    The 3/4 is the slope of the lines, a line that crosses both lines with the shortest distance has a slope of -4/3

    using the new line 3: y = -4x/3 we can now find the intercept points for lines 1 and 2 with line 3

    3x/4 - 10/4 = -4x/3
    9x-30 = -16x
    x = 6/5
    y = 3/4 * 6/5 - 10/4 = 18/20 - 50/20 = -32/20 = -8/5

    3x/4 + 5/8 = -4x/3
    18x+15 = -32x
    x = -3/8
    y = 3/4 * 3/8 + 5/8 = 9/32 + 20/32 = 29/32

    Point 1 = (6/5, -8/5)
    Point 2 = (-3/8, 29/32)

    Then the ditance between these two points is

    sqrt((6/5+3/8)^2+(-8/5-29/32)^2) = 2.96...

    This is the shortest distance bewtween your two lines.

  3. #3
    Addicted Member Active's Avatar
    Join Date
    Jan 2001
    Location
    Lat: 13 4' 46" N, Long: 80 15' 20" E
    Posts
    209
    Well illuminator..

    Your Idea of Introducing a Third perpendicular line was
    good but not simple enough.

    Proof :
    You made a simple calculation mistake

    /* second part */
    3x/4 + 5/8 = -4x/3
    18x+15 = -32x
    x = -3/8
    y = 3/4 * 3/8 + 5/8 = 9/32 + 20/32 = 29/32
    3x/4 + 5/8 = -4x/3

    (6x+5)/8 = -4x /3

    3(6x+5)=-32x

    or x=-3/10 (not -3/8)

    therfore y=2/5

    and the two points are (6/5,-8/5) and (-3/10,2/5)

    and distance between these two points is 5/2 = 2.5

    ----
    Here is a much simpler way...

    As we see from the equations

    3x-4y-10=0
    6x-8y+5=0

    are not parallel to the x -axis or y-axis

    Therefore they intersect both the axes at some points.

    The first equation for example Intersects x-axis at
    (10/3,0)
    how ??
    The y co-ordinate at the point the line cuts x-axis is zero.
    put y=0 in the equation

    3x-10=0 ==> x = 10/3 and y=0
    therefore we found one point on the line 3x-4y-10=0

    you got the the other line equation 6x-8y+5 =0


    use your formula ...
    a,b -> 10/3,0

    d = (|Aa+Bb+C|) / (squareroot(A^2+B^2)

    d = |(6*10/3)+(-8*0)+5| / Sqr((6^2+(-8)^2))

    d = 2.5

    --------
    You can also do it the otherway..
    Similarly you can take a point on the second line
    6x-8y+5=0 and find perpencicular distance to the other line
    3x-4y-10=0

    at the point of intersection line 6x-8y+5=0 with x-axis, y=0
    6x-8(0)+5=0

    ==> x = -5/6 and y=0

    therfore use you perpendicular distance formula..
    (a,b) -> (-5/6,0)

    d = |3*(-5/6)+(-4*0)-10| / Sqr(3^2+(-4)^2)
    d = (25/2)/5
    d = 2.5

    ---
    If you can't beat your computer at chess, try kickboxing !!!
    [Download Tag Editing Tools.]

  4. #4

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Thanks for the replies guys!

    I got it!
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width