- Home /

# Find intersecting points between vectors

Hi,

I try to find the blue vector in my image. Hopefully the the picture says enough, otherwise I'll be happy to elaborate. Any help would be appreaciated! The unit vectors and constants are known and will all be within reasonable bounds. XY-space.

### People who like this

Gareth Rees' answer to this post on stackoverflow describes the math step by step, to find if 2 vectors are intersecting (and at what point).

https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

@MacDx That wouldn't help, he wants the intersection of two vectors which origins moves in a line

**Answer** by iJuan
·
May 12, 2018 at 01:06 AM

I'll just give you the code and hope not to have missed anything lol

```
Vector2 V1;
Vector2 V2;
float const1;
float const2;
Vector2 U1 = V1 / V1.length() * const1;
Vector2 U2 = V2 / V2.length() * const2;
float t = ((U1.y + U2.y) * V2.y/V2.x + U2.x + U1.x)/(V1.y - V1.x * V2.y / V2.x);
Vector2 point = t * V1 + //If it doesn't works, set this to -
new Vector2(V1.y, -V1.x) * const1 / V1.length();
```

I do really hope I've not missed anything...

Will check it in a while. Both vectors are 2D,right? And they are all centered in the origin? That math will only work if your center is the origin

Took away my old answer, found out a minor mistake by me, works like a charm! Thanks a lot!

### Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. **Please note, Unity Answers is now in read-only so we can prepare for the final data migration.**

For more information and updates, please read our full announcement thread in the Unity Forum.

### Follow this Question

### Related Questions

Constant time way to find intersection of two objects when given speeds and directions of both? 3 Answers

Need to normalize vectors? 2 Answers

Vector3 array from external .txt file 1 Answer

Make an object move to a given point by rotating to the correct direction first. 1 Answer

Change rigidbody direction 1 Answer