Subscribe via feed.

Math Problem

Posted by ragknot on August 7, 2013 – 10:36 pm

Given four XY points. Let’s name them A,B,  C,D,  E, F,  and  G, H, where A,C,E and G are x values and the other are y values.

Two points, A,B to C,D makes one line and D,E and F,G makes another line.

First part,   Do the intersect? (Yes or No)

If Yes, then what is the X,Y point where they do intersect?

What math computation gives the answers?


This post is under “Tom” and has 9 respond so far.
If you enjoy this article, make sure you subscribe to my RSS Feed.

9 Responds so far- Add one»

  1. 1. DP Said:

    The two lines do not necessarily intersect, but could. You have not defined where any specific point is in relation to another point or the origin other than defining them as (A,B) and so on, so there is no way to tell if the lines will or will not intersect.
    My logic may be flawed, but IF the lines intersect, I believe it will be at the “average value” point. I don’t know if this has a specific name so that is what I’m giving it. The point is: ([A+C+E+G]/4 , [B+D+F+H]/4) This is incorrect.
    Maybe this is a special case and I am missing something. This is all without looking up how to do it, or remembering back to my algebra days.

    BTW, I think you meant to say: “A,C,E and ‘G’ are x values” in your problem statement (not ‘F’) and that “E,F and G,H make the other” (not D,E and F,G).

  2. 2. DP Said:

    OK…the “average value point” I explained in the previous post is a special case. From here-on I will pretend I didn’t post that.
    Again, we have no way of knowing if the lines intersect without more information about the points. However, IF the lines do intersect, we know the equations to use to find the intersecting point using only the 4 sets of points given.
    The equation for a line is y=mx+b, where x&y are coordinates of a point on the line, m is the slope, and b is the y-axis intersection (where the line would/does cross the y-axis).
    The point of 2 intersecting lines has the same x&y values, and is a point along both lines, so must fit into the equation for both lines. For that reason, we can set the two line equations equal to eachother for both x and y.

    For (A,B) -> (C,D):
    y = mx + b; m = (D-B)/(C-A) and b = B-mA = D-mC.
    So y = [(D-B)/(C-A)]*x + {B – [(D-B)/(C-A)]*A} = [(D-B)/(C-A)]*x + {D – [(D-B)/(C-A)]*C}

    For (E,F) -> (G,H):
    y = mx + b; m = (H-F)/(G-E) and b = F-mE = H-mG.
    So y = [(H-F)/(G-E)]*x + {F – [(H-F)/(G-E)]*E} = [(H-F)/(G-E)]*x + {H – [(H-F)/(G-E)]*G}

    Again, set the equations equal (I’ll just use the first version of each, but you can use either):
    [(D-B)/(C-A)]*x + {B – [(D-B)/(C-A)]*A} = [(H-F)/(G-E)]*x + {F – [(H-F)/(G-E)]*E}

    Now solve for x:
    x = ({F – [(H-F)/(G-E)]*E} – {B – [(D-B)/(C-A)]*A})/{[(D-B)/(C-A)] – [(H-F)/(G-E)]}
    This is the x-value of the intersecting point.
    Plug this back into any of the 4 y-equations to get the y-value. Again, I’ll just choose the first:
    y = [(D-B)/(C-A)]*({F – [(H-F)/(G-E)]*E} – {B – [(D-B)/(C-A)]*A})/{[(D-B)/(C-A)] – [(H-F)/(G-E)]} + {B – [(D-B)/(C-A)]*A}

    As I said before, you can use either of the y-equations (where the ‘b’ value is defined by either the first or second defined point) at any step within the problem. As you can tell, it won’t metter since you need all 8 values (x&y of each of the 4 points) to get both x & y of the intersecting point.

  3. 3. ragknot Said:

    DP,
    Oh, right, F was suppose to by a y value.
    I will have to check out other data.

    Next let’s suppose the A,B,C,D,E,F,G,H values are
    0,1,8,9,2,7,6,3.

    First Question , do they intersect?

    Second Question, if yes, then what would be the X and Y values of the intersection?

  4. 4. ragknot Said:

    DP,
    The equations you entered are about correct, but do they intersect? I will review more of you text to see if you did do that also.

    The reply #3 I give should make it easy for others to figure out the X and Y intersection, even if they don’t know the complexity you did DP.!!!

    Thanks

    Later I will give equations that most could do.

  5. 5. DP Said:

    I did not do a proof of intersection. I will leave that for someone else.
    For post #3: If you were to plot these points you can see that the lines will infact intersect. By plugging the values in to my equations, the intersection point is (4,5) which happens to lie on both lines.
    Given specific points, you can calculate m & b for each line, which significantly cleans up my previous equations.

  6. 6. DP Said:

    For (A,B) -> (C,D):
    m = (D-B)/(C-A) = (9-1)/(8-0) = 1
    b = B-mA = D-mC = 1-(1)*0 = 9-(1)*8 = 1
    y = (1)*x+1 = x+1

    For (E,F) -> (G,H):
    m = (H-F)/(G-E) = (3-7)/(6-2) = -1
    b = F-mE = H-mG = 7-(-1)*2 = 3-(-1)*6 = 9
    y = (-1)*x+9 = -x+9 = 9-x

    Since we are looking for the intersection point, x(line 1) = x(line 2) & y(line 1) = y(line 2)
    set the [2] y equations equal ot get:
    x+1 = 9-x
    solve for x:
    x=4
    plug back in to any y equation:
    y=5

  7. 7. DP Said:

    Just to be thourough, what would it look like if instead of (0,1),(8,9),(2,7),(6,3) your sets were (0,1),(2,7),(8,9),(6,3)?

    For (A,B) -> (C,D):
    m = (D-B)/(C-A) = (7-1)/(2-0) = 3
    b = B-mA = D-mC = 1-(3)*0 = 7-(3)*2 = 1
    y = (3)*x+1 = 3x+1

    For (E,F) -> (G,H):
    m = (H-F)/(G-E) = (3-9)/(6-8) = 3
    b = F-mE = H-mG = 9-(3)*8 = 3-(3)*6 = -15
    y = (3)*x+(-15) = 3x-15

    set the [2] y equations equal to get:
    3x+1 = 3x-15
    solve for x:
    **fail**
    This is good news, since the lines are parallel. We can tell because the slope for each line is 3.

  8. 8. DP Said:

    I guess the point is, check the slopes first…
    For (A,B) -> (C,D): m = (D-B)/(C-A)
    For (E,F) -> (G,H): m = (H-F)/(G-E)
    If they are equal, the lines either are parallel or are congruent (correct use of that word?).
    Otherwise the lines WILL intersect (assuming only 2 dimensions, or the the un-stated z-dimension is ‘0′). I guess the question then becomes, “do the lines intersect within the segment listed?” which sould be able to be answered with my equations. The answer is yes as long as the x-value is within the x-values given for both lines (between A&C and between E&G) and the same for the y-values.

  9. 9. ragknot Said:

    DP!
    That looks good, but I will test it.
    Can you review mine..

    This Excel function gives a string of several parts.
    For my real function I use this to get all my needs.

    Type InterSectType
    X As Double
    Y As Double
    I As Boolean
    T As String
    End Type

    ==========================================================

    Function Intsec(A As Double, B As Double, C As Double, D As Double, E As Double, F As Double, G As Double, H As Double) As String
    Dim J As Double
    Dim I As Double
    Dim K As Double
    Dim M As Double
    Dim N As Double
    Dim XIntsec as Double
    Dim YIntsec as Double
    J = (H – F) * (C – A) – (G – E) * (D – B)
    I = (G – E) * (B – F) – (H – F) * (A – E)
    K = (C – A) * (B – F) – (D – B) * (A – E)
    If J <> 0 Then
    M = I / J
    N = K / J
    Else
    If (A = E) And (B = F) Then
    If (C = G) And (D = H) Then Intsec = “False Same Line”: Exit Function
    XIntsec = A
    YIntsec = B
    Intsec = “True, ” & ” X=” & XIntsec & “, Y=” & YIntsec
    Else
    Intsec = “False Parallel”
    End If
    Exit Function
    End If
    If M >= 0 And M < = 1 And N >= 0 And N <= 1 Then
    XIntsec = A + M * (C – A)
    YIntsec = B + M * (D – B)
    Intsec = “True, ” & ” X=” & XIntsec & “, Y=” & YIntsec
    Else
    Intsec = “False”
    End If
    End Function

Post a reply




PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\php_mssql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\php_pdo_mssql.dll' - The specified module could not be found. in Unknown on line 0