0

I'm sorry that the title is vague, but I don't know if there is a scientific name for the vector that I'm trying to calculate.

See sketch

pic

The two black lines are vectors pointing from some origin. The red lines are the perpendicular vectors of the black vectors. I want to calculate the blue vector which points to where the red vectors intersect.

I'm using this as a way to 'combine' two vectors. I'm looking for a way to find the "maximum" vector that moves the amount of both instead of just simply adding the vectors.

Examples:

If two vectors are equal, adding them together would produce a vector twice as long. Instead, my vector should just be the size of one of the original vectors.

If one vector is longer than the other but in the same direction, my vector should be the longer one.

On the other hand, if the two vectors are orthogonal then my vector will be equal to the vectors added together.

If there is a scientific name for this vector that someone knows about then please let me know so I can do my own research. :)
Thanks.

Edit:
Based on dpmcmlxxvi's post,
I came up with the two equations to solve for the x and y intersection points.

xi = (m1 * x1) - (m2 * x2) - y1 + y2
yi = (m1 * xi) - (m1 * x1) + y1

Edit:
The above equations had issues with infinite values of m (when the perpendicular lines were vertical). I found a Wiki article: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line
and used the "Given two points on each line" equations which work great as long as the lines aren't parallel.

Bradley Odell
  • 1,248
  • 2
  • 15
  • 28
  • If your two black vectors are co-linear then your definition is not well-defined since their normals intersect either everywhere or nowhere. And, no, I'm not aware of a name for this type of vector composition. – dpmcmlxxvi Jul 29 '15 at 20:03
  • Yeah, you're right. I'm writing code to do this and I could always add in an additional check to determine whether the vectors are co-linear. Other than that, do you know what math would calculate the vector I'm looking for? – Bradley Odell Jul 29 '15 at 20:16
  • Good you found an answer. However, I would point out that the answer I linked to does not require computing the slope the way you did above. – dpmcmlxxvi Jul 30 '15 at 00:06

2 Answers2

1

First, see my comment above about your definition not working for parallel vectors. Second, the following should get you the intersection point.

  1. The math to find the perpendicular line to each black vector is in a previous answer.

  2. Once, you have a perpendicular line for each black vector, you'll have two free parameters, one for each line.

  3. Equate the two lines and that will give you the free parameters and yield the point of intersection.

  4. Subtracting the intersection point from the origin gives you the blue vector you want.

Community
  • 1
  • 1
dpmcmlxxvi
  • 1,292
  • 1
  • 9
  • 13
1

With planar homogeneous coordinates the locations at the vector ends are

P_1 = (x_1,y_1,1) 
P_2 = (x_2,y_2,1)

A line in planar homogeneous coordinates is described by three values (a,b,c) such that the equation of the line is a*x+b*y+c=0 The perpendicular line through each point has coordinates

L_1 = [x_1,y_1,-x_1^2-y_1^2] 
L_2 = [x_2,y_2,-x_2^2-y_2^2]

The location of the intersection of two lines is defined by Q=L_1 × L_2 where × is the vector cross product. Thus the result in homogeneous coordinates is

Q = | y_2*(x_1^2+y_1^2)-y_1*(x_2^2+y_2^2) |
    | x_1*(x_2^2+y_2^2)-x_2*(x_1^2+y_1^2) |
    |       x_1*y_2-x_2*y_1               |

The cartesian coordinates of Q are

     y_2*(x_1^2+y_1^2)-y_1*(x_2^2+y_2^2) 
x = -------------------------------------
             x_1*y_2-x_2*y_1

and

     x_1*(x_2^2+y_2^2)-x_2*(x_1^2+y_1^2)
y = -------------------------------------
             x_1*y_2-x_2*y_1
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • I just went with the simpler approach, mainly because I don't fully understand homogeneous coordinates. Thanks anyway for the reply and the edit to my post, I didn't know you could inline images. – Bradley Odell Jul 29 '15 at 22:33
  • Just use the expression for `x` and `y` and plug and chug the results. The two vectors are `(x_1, y_1)` and `(x_2, y_2)` which you use in the expressions above. It's really a one step approach. – John Alexiou Jul 29 '15 at 23:16
  • I found this Wiki article: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line – Bradley Odell Jul 29 '15 at 23:45
  • I used the "Given two points on each line" approach because the solve the equations method had trouble with infinite slopes (m values). I don't understand how your equation could work if you only give the 4 values instead of 8 required to represents 2 lines. – Bradley Odell Jul 29 '15 at 23:48
  • For each line you only need 2 values. The orientation of the line (angle) and the offset from the origin. The three line coordinates `(a,b,c)` can be found by the angle `psi` and offset `d` by `(a,b,c)=(cos(psi),sin(psi),-d)`. Only two are needed for a planar line. – John Alexiou Jul 30 '15 at 00:43
  • Exactly. Homogeneous coordinates are useful in avoiding problems with infinite slope. – John Alexiou Jul 30 '15 at 00:51