1
$\begingroup$

Let say I have this diagram,

enter image description here

How to find the direction vector passing through the intersection point of two straight lines?

Update: new vector is the bisector of two lines and vector may be arbitrary.

  • 0
    Do you mean for that vector to be the angle bisector of the other two?2012-04-03
  • 0
    yes I mean this2012-04-03
  • 0
    Then why don't you edit the question so it says what you actually mean?2012-04-03
  • 0
    @GerryMyerson, updated now. Thanks. Can you please answer this if you can?2012-04-03
  • 0
    What's wrong with the two answers you already have? Anyway, I'm afraid it's bedtime now. It will have to wait until tomorrow.2012-04-03
  • 0
    @GerryMyerson, Actually sometimes the direction vectors are wrong. Please see the comments.2012-04-03

4 Answers 4

1

It seems that what OP really wants is, given direction vectors $(1,a)$ and $(1,b)$, find the direction vector of their angle bisector.

I'm going to assume $0\le a\le b\lt\infty$, and let OP figure out the necessary modifications if any for other parameter ranges.

Let $\alpha$ be the angle the 1st direction vector makes with the $x$-axis, and let $\beta$ be the angle the 2nd direction vector makes with the $x$-axis. Then we have $\tan\alpha=a$, and $\tan\beta=b$. The bisector makes an angle $(\alpha+\beta)/2$ with the $x$-axis, so its direction vector is $(1,\tan((\alpha+\beta)/2))$. By the half-angle formula for the tangent (see, e.g., http://en.wikipedia.org/wiki/Tangent_half-angle_formula) we have $$\tan\left({\alpha+\beta\over2}\right)={\tan(\alpha+\beta)\over1+\sqrt{1+\tan^2(\alpha+\beta)}}$$ Combine this with the addition formula for the tangent, $$\tan(\alpha+\beta)={\tan\alpha+\tan\beta\over1-\tan\alpha\tan\beta}$$ and the values $\tan\alpha=a$ and $\tan\beta=b$ already mentioned, and you have a formula for the direction vector $(1,\tan((\alpha+\beta)/2))$ of the bisector. I think that second component simplifies to $${a+b\over1-ab+\sqrt{(a^2+1)(b^2+1)}}$$

  • 0
    Thanks. But I found Christian Blatter solution is very simple and always gives correct result for any two vectors.2012-04-04
1

You can do this by calculating the angle between the two and then finding the appropriate direction vector. Using that the angle between line passing through the points $(0,0)$ and $(x,y)$ and between the $x$-axis is given by $\arctan\frac{y}{x}$.
Then the angle between the given two lines will be: $\arctan\frac{3}{2}-\arctan\frac{4}{8}$ (do you see why?)
So, the angle between the desired line and the $x$-axis will be: $$\frac{1}{2}\left(\arctan\frac{3}{2}-\arctan\frac{1}{2}\right)+\arctan\frac{1}{2}=\frac{1}{2}\left(\arctan\frac{3}{2}+\arctan\frac{1}{2}\right)$$ Once again - do you see it?
Now, the direction vector will be $(1,y)$, where $y=\tan\left[\frac{1}{2}\left(\arctan\frac{3}{2}+\arctan\frac{1}{2}\right)\right]$.
You can calculate it with a calculator or using the identities of the $\tan$ and $\arctan$ functions.
Edit: The $\arctan$ function returns values between $-\frac{\pi}{2}$ and $\frac{\pi}{2}$ rad ($-90$ and $90$ degrees). So, if a point $(x,y)$ is in the first or fourth quadrant, then the angle between the line and the $x$-axis will be in that interval and will be exactly $\arctan\frac yx$. But if it's not, then you have to "repair" the angle: If $(x,y)$ is in the second quadrant (i.e. $x<0, y>0$) then the angle should be between $\frac{\pi}{2}$ and $\pi$ rad. The correct way to get the angle will be $\pi+\arctan\frac yx$.
If $(x,y)$ is in the third quadrant (i.e. $x<0, y<0$) then the angle should be between $-\pi$ and $-\frac{\pi}{2}$ rad. The correct way to get the angle will be $-\pi+\arctan\frac yx$.
(If you're used to calculating in degrees, replace $\pi$ by $180$ degrees everywhere).
Edit 2: If you want to calculate the angle of a line passing through two given points $(x_1,y_1)$, $(x_2,y_2)$ with the $x$-axis, You should replace each $\arctan\frac yx$ with $\arctan\frac {y_2-y_1}{x_2-x_1}$

  • 0
    Thanks. I will check it with my application and let you know2012-04-03
  • 0
    You should get $\frac18(\sqrt{65}-1)\approx 0.8827$2012-04-03
  • 0
    Not sure but you have different value than @pedja.2012-04-03
  • 0
    Not sure? about what?2012-04-03
  • 0
    Now both have correct value. But I need to check this with my app2012-04-03
  • 0
    Is this work for any arbitrary 2 direction vectors, (x1,y1) and (x2,y2)?2012-04-03
  • 0
    I can find angle using, http://stackoverflow.com/questions/4294638/how-to-calculate-angle-between-two-direction-vectors-that-form-a-closed-open-sha2012-04-03
  • 1
    @user960567: Yes, it will, as long as both $(x_1,y_1)$ and $(x_2,y_2)$ are in the first quadrant. If they are not, then, in some cases, the values of $\arctan$ need to be corrected by $\pi$, to have the correct angle.2012-04-03
  • 0
    Can you please tell me how to check this? I am getting 2 correct slopes with your formula and 1 wrong? Points of triangle, (147,120), (237,81),(255,168)2012-04-03
  • 0
    Dennis, please provide me the answer with 2 arbitrary direction vectors which may be in any quadrant. I will be very very thankful to you. I am very upset since 2 days. Please help me.2012-04-03
  • 1
    @user960567: I edited my post and added the correct way to calculate angles with the $x$-axis. You should be able to continue from here.2012-04-03
  • 0
    Great man. But I am confused that you have mention second quadrant at 2 places. Also, for 2 points(x1,y1) and (x2,y2) then how to check the quadrants.2012-04-04
  • 0
    Dennis, you help me very much. I am very thankful for you. But I have found Christian Blatter solution is very simple and always gives me correct result for any any two vectors. But, I am very thankfull for your help. Any comment about the solution is welcome.2012-04-04
1

Let's denote direction vector as $v$ ,then :

$$v=\left(1,\tan\left(\frac{\arctan{\frac{3}{2}}+\arctan{\frac{1}{2}}}{2}\right)\right)\approx(1,0.8828)$$

  • 0
    I am not getting 1.1328 result. Can you please check it?2012-04-03
  • 0
    @user960567 fixed2012-04-03
  • 0
    Not sure but you have different value than @DennisGulko.2012-04-03
  • 2
    @user960567 Our solutions are basically the same...2012-04-03
  • 0
    PLease see the comment above if you can answer this.2012-04-03
  • 0
    @user960567 I am suggesting you to ask a new question in which you can describe in details problem you are facing....2012-04-03
  • 0
    But the question is same. Only the direction vector is arbitrary.2012-04-03
1

Normalize the two given vectors, i.e. compute $$e_a:={a\over |a|}={1\over\sqrt{13}}(2,3)\ ,\quad e_b:={b\over|b|}={1\over\sqrt{5}}(2,1)\ .$$ Then the angle bisector will pass through the point $$p:=e_a+e_b=\Bigl({2\over\sqrt{13}}+{2\over\sqrt{5}},{3\over\sqrt{13}}+{1\over\sqrt{5}}\Bigr)\doteq(1.44913,1.27926)$$ whose argument is $\arctan(0.882782)=0.723221=41.44^\circ$.

The following figure shows the geometric intuition behind the above computation:

enter image description here

  • 0
    I think is not correct see the above calculations2012-04-03
  • 0
    @user960567: My values coincide with the results of Dennis Gulko and pedja.2012-04-03
  • 0
    Yes got that. This seems to me more straight forward. Is this work for a vector between any 2 points? Can you please show me how?2012-04-04
  • 0
    I have extensively tested all solutions. But your solution is always gives me correct values in my application. Dennis solution is also fine but sometimes I cannot get desired result. Your solution is also very very simple. Can you explain a little how you found this formula?2012-04-04
  • 1
    @user960567: I did what you would do to solve this problem with ruler and compass: Draw a circle with center at the intersection of the two lines; then construct the median of the two points where the circle intersects the two lines.2012-04-04
  • 0
    If possible, can you please explain with figure. It will help me and others to solve similar problems in future. BTW, thanks again.2012-04-04
  • 0
    Wow, It's great. Thanks again2012-04-04