Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by cgeopapa · Oct 22, 2017 at 11:48 AM · vector3geometryracingturn

Get the raod turn radius

So I have two Vector3s A and B they represent the beginning and the end of a road turn (for a racing game). They also look at the direction of the road. Now what I want is given these two vectors to find the radius of the circle that is created.alt text

Here is a visual representation of what I want to find.

Note that in the shape I have vector2s because I dont care about the vector3.y so I have replaced the vector2.y with the vector3.z.

img-20171022-143920.jpg (160.5 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by elenzil · Oct 23, 2017 at 01:13 AM

nice question.

so you have A and B as points on the circle, and then you also have vA and vB, the vectors tangent to the circle at those points. from those, you can create perpendicular vAP and vBP by rotating vA and vB 90º each. since they're perpendicular to the tangents, that means they're normal to the surface of the circle, and they will intersect at the center of the circle.

There's a billion line-intersection routines in the world, and LineLineIntersection() from here looks reasonable.

There's a couple edge-cases where this approach won't work: 1. if points A and B are the same, it's impossible to know. also as vA and vB approach being parallel or anti-parallel, the accuracy will decrease. 2. if A and B are on exactly opposite sides of the circle, then the line-intersection approach will not yield a specific solution. I would add some logic before the line-intersection stuff which tests the dot-product of vAN and vBN. (vAN = the normalized version of vA). if that value is close to -1 (eg, less that -0.999, say) then you can conclude that A and B are on opposite sides of the circle, and the center of the circle is (A + B) / 2.

Comment
Add comment · Show 1 · 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 elenzil · Oct 23, 2017 at 01:18 AM 0
Share

also in general, when you need functions for stuff like line-intersect-line, you can't do better than to visit the pages of Paul Bourke. he's correct and succinct.

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.

Follow this Question

Answers Answers and Comments

88 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get random point on the perimeter of a rectangle? 1 Answer

How to rotate Vector3 to EulerAngle? 1 Answer

Distance between a point and any point on an object 0 Answers

Shortest distance between two meshes/colliders 3 Answers

Car drives sideways, doesn't turn 1 Answer


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