• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Paperfrog · May 11, 2018 at 03:29 PM · vectorintersectionconstant

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 wit$$anonymous$$n reasonable bounds. XY-space.

alt text

findvector.jpg (50.4 kB)
Comment
iJuan

People who like this

1 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MacDx · May 11, 2018 at 11:31 PM 0
Share

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

avatar image iJuan · May 12, 2018 at 12:14 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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

I'll just give you the code and hope not to have missed anyt$$anonymous$$ng 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 t$$anonymous$$s to -
                 new Vector2(V1.y, -V1.x) * const1 / V1.length(); 

I do really hope I've not missed anyt$$anonymous$$ng...

Comment
Paperfrog

People who like this

1 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image iJuan · May 12, 2018 at 05:41 PM 0
Share

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

avatar image Paperfrog iJuan · May 12, 2018 at 05:45 PM 0
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

83 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

transform position vectorially 2 Answers

Vector2 scalar multiplication issue 1 Answer

How to get the tangent and normal of a collision? 1 Answer

How to detect if target is inside an "arc" area? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges