E
E
Elena2021-08-18 14:24:32
Geometry
Elena, 2021-08-18 14:24:32

How do you know if vectors intersect?

Vector data:
x1-0; y1-0;
x2-10; y2-0;
Their projection onto the axis:
Vx1=40; Vy1=0;
Vx2=-30; Vy2=0;
If you draw them, you can see that they intersect, but how can I prove it all, by numbers?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-08-18
@Elena0394

Enter 2 variables t and q - this is "time" on the first and second beam, make 2 equations. Solve them - find the crossing time on each ray. Make sure that the intersections at t>=0, q>=0:

x1+t*vx1=x2+q*vx2
y1+t*vy1=y2+q*vy2

we need to check that it has a solution. Convert it to standard form:
t*vx1-q*vx2=x2-x1
t*vy1-q*vy2=y2-y1

Solve the system by Krammer's method. If system determinant != 0 - then find 2 variables q and t. Check that they are both non-negative.
If the determinant is equal to zero, then the lines either do not intersect at all, or coincide. They coincide if both auxiliary determinants of the system are equal to 0.
In this case, you need to check that the rays intersect along a segment or a ray. To do this, you need to check whether the beginning of the second ray lies on the first one and vice versa. For this check, you can use the cross product of vectors. Count the vector {x2-x1, y2-y1} and multiply by the vector {vx1, vy1}. These 2 vectors either look in the same direction (and there is an intersection), or in different directions. In the first case, the vector product will be positive, in the second - negative. Consider the zero product as positive - this means that either the points coincide or the direction vector is zero.
Those. the whole algorithm
1) Read 3 determinants using Krammer's method
2) If the main determinant is not 0, read q and t. There is an intersection if q>=0 and t>=0.
3) If the main determinant is 0, but at least one of the auxiliary determinants is not 0, then there is no intersection.
4) Read the vector product {x2-x1, y2-y1} by {vx1, vy1}. If it is non-negative, then there is an intersection.
5) Read the vector product {x1-x2, y1-y2} by {vx2, vy2}. If it is non-negative, then there is an intersection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question