Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by alphapapa · Dec 03, 2013 at 09:17 AM · anglevector

Best way to calculate angle between series of Vector3 points

I'm trying to calculate the angle of acuteness between a series of Vector3 points. They will eventually be a waypoint path and the angle will be used to determine how much the agent should slow down based on a sharp turn. I want to do this at waypoint creation rather than when the agent navigates the path. The problem I am having with Vector3.Angle is that it is calculating the angle from the origin point as it treats them as vectors.

Just wondering what would be the best method of going about this. I'm guessing it would probably be normal trigonometry in some capacity but am not sure. I'm trying to determine the vector that is at right angles to both points by using Cross Product but it's not working as intended.

Here's some pictures of what I'm hoping to achieve.

alt text

alt text

angle.jpg (44.4 kB)
angle2 copy.jpg (45.0 kB)
Comment
Add comment · Show 6
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 CHPedersen · Dec 03, 2013 at 09:24 AM 0
Share

The second drawing looks a little inaccurate, but I'm guessing the almost-vertical edges of those triangles should ideally be totally vertical, like in the top drawing, right?

Here's a question, though: If the use case of this is to slow down the character's movement based on how sharp a turn is, why do you need the angles in the drawing? Shouldn't you be using the angle between two consecutive road segments? Following the logic above, imagine if you have two consecutive road segments which are almost horizontal in the drawing. They'd get an almost 90 degree angle against those vertical lines, making for a drastic slow-down, right? But if they're almost parallel, the slow-down should close to 0 ins$$anonymous$$d - which you'd get if you took the angle between the segment vectors ins$$anonymous$$d.

avatar image alphapapa · Dec 06, 2013 at 11:27 AM 0
Share

Do you mean somthing like this?

alt text

angle.jpg (322.5 kB)
avatar image CHPedersen · Dec 06, 2013 at 11:41 AM 0
Share

Yes, that is exactly the angle I mean. :) Doesn't that better denote how sharply the line turns and thus, how much you need the character to slow down?

avatar image CHPedersen · Dec 06, 2013 at 11:55 AM 0
Share

Well... By "exactly", I mean you have the right concept, but you've drawn it slightly wrong. :) The angle I'm talking about is the angle between two consecutive road segments, if they shared a starting point. That's not entirely the same as you drew. Basically, I'm suggesting this, where the P's are the points, the V's are the vectors between them. The angle you should calculate is theta, and it would simply be Vector3.Angle(V0, V1) in code:

Angle between road segments

anglebetween.png (16.0 kB)
avatar image CHPedersen · Dec 06, 2013 at 11:56 AM 0
Share

Oh crud, I forgot adding the "V1" label. But it's the lower segment, of course.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I get a normalized vector2D from an angle? 1 Answer

How to find how much an object has rotated? 2 Answers

Trouble Understanding Vector3.Angle() Result 2 Answers

How can I calculate the Vector3 b using Vector 3 a pos with an angle? 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