Results 1 to 7 of 7

Thread: Math help please.

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Math help please.

    This is a general math question that is based on parallel and perpendicular lines.

    Let us say we have two parallel lines, given by

    y = mx+c1 and y = mx + c2

    I know a point on the first line (x1,y1) and the perpendicular distance (d) between these two lines.

    c1 is known, c2 is unknown.

    How can I find a point on the other line ?

    Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Math help please.

    If you know x1,y1 then you can calculate c1, provided that "m" is known.

    y1 = m*x1 + c1 => c1 = y1 - m*x1

    You can then take a line which is perpendicular to the first one and goes through (x1,y1) by changing the m parameter (as it is a tangent). Calculating the other point based on the distance shouldn't cause you any problems then.

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Math help please.

    c1 is already known. So no need to calculate c1.

    You can then take a line which is perpendicular to the first one and goes through (x1,y1) by changing the m parameter (as it is a tangent).
    Yes I got the equation of the perpendicular line passing thru (x1,y1). This point is also on the line y = mx + c1

    Calculating the other point based on the distance shouldn't cause you any problems then.
    This is where the problem is. Let us assume we have to find the point (x2,y2) which is lying on the line y = mx + c2.

    We know, (y2-y1)/(x2-x1) = -1/m. Also, d^2 = (y2-y1)^2 + (x2-x1)^2

    How should I proceed from here ?

    Thanks a lot.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Math help please.

    Do you know c2 then? Because if so, then you don't need the distance as there is only one point lying on the second line and on a line perpendicular to the first line and you can calculate it without knowing the distance between lines (I assume they are parallel). If you don't know c2, you can calculate it if you know the distance between those two parallel lines.

    y1 = mx+c1
    y2 = mx+c2
    for x=0:
    y1 = c1
    y2 = c2
    so c2-c1 = d => c2 = d+c1

    Edit: I think one of my assumptions is not reliable (c2-c1 is not the perpendicular distance between the lines), better not use that.
    Last edited by wysota; 2nd October 2006 at 19:51.

  5. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Math help please.

    Earlier even I thought |c2-c1| = d, but only later realized that this assumption is wrong, and then posted the problem here.

    Do you know c2 then?
    No we do not know that value of c2. We only know the perpendicular distance between the two parallel lines which is d.

    At this point we have the following information.

    Two parallel lines

    y = mx+c1; c1 is known
    y = mx + c2; c2 is unknown

    A line perpendicular to y = mx + c1 i.e., y = (-1/m)x + c1.
    The intersection point of the y = mx + c1 & y= (-1/m)x + c1 is also known. Let it be (x1,y1)

    I need to find, the intersection point of the line y = (-1/m)x+c1 on the line y = mx+c2.

    Please someone help me solve this one.

    Thanks a lot.

  6. #6
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Math help please.

    Quote Originally Posted by munna View Post
    Two parallel lines

    y = mx+c1; c1 is known
    y = mx + c2; c2 is unknown

    d - distance between lines is known

    The intersection point of the y = mx + c1 & perpendicular line is also known. Let it be (x1,y1)

    I need to find, the intersection point of the line perpendicular line and the line y = mx+c2.
    y = mx + c1: c1 is known, some point (x1, y1) on the line is known, so you can compute m.

    mx - y + c1 = 0
    mx - y + c2 = 0
    Equation for distance between two parallel lines: d = abs(C1-C2) / sqrt(A^2+B^2)

    d * sqrt(m^2+(-1)^2) = abs(c1-c2)
    Left side of equation is known, so lets assume d * sqrt(m^2+1) = L:
    L = abs(c1-c2)
    c1 - c2 = L or c1 - c2 = -L
    c2 = c1 - L or c2 = c1 + L

    Equation for perpendicular line: y = -(1/m)x + cp
    y = -(1/m)x + cp: m is known, some point (x1, y1) on the line is known, so you can compute cp.

    Now you have two perpendicular lines: y = mx + c2 and y = -(1/m)x + cp, where m is known, c2 is known and cp is known. You can compute the point where they intersect, which is the point which you are looking for. In fact, you'll get two points, cause c2 = c1 +/- L
    The Wheel weaves as the Wheel wills.

  7. The following user says thank you to danadam for this useful post:

    munna (3rd October 2006)

  8. #7
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Math help please.

    You might want to check out QLineF:
    http://doc.trolltech.com/4.1/qlinef.html

    Given a line L1, you can get anotherone that has a distance of d to that by taking a copy of L1 and translate it by L1.normalVector() * d.
    It's nice to be important but it's more important to be nice.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.