PDA

View Full Version : Math help please.



munna
2nd October 2006, 14:03
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.

wysota
2nd October 2006, 17:41
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.

munna
2nd October 2006, 18:12
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.

wysota
2nd October 2006, 18:33
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.

munna
2nd October 2006, 19:36
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.

danadam
3rd October 2006, 08:53
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

axeljaeger
8th October 2006, 10:00
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.