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
0
Question by gamedevpadawan · Jan 06, 2015 at 04:22 PM · anglevectoranglesvectors

2D angle of two Vec3

How can I calculate 2D angle of two Vec3? alt text

I am trying to find angle between wing forward vector and velocity vector. I found on forum nice code for angle between two vectors. My problem is when my object turns left or right the velocity vector does not turns with object. Of course it`s normal. I need to find plane (XY) angle or make new vector based on velocity vector and turning with plane. Because alt text

this falsifies my angle.

Thank you.

Comment
Add comment · Show 7
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 Owen-Reynolds · Jan 06, 2015 at 05:08 PM 1
Share

The trick is to think of which 2D plane to measure over, which is usually called a projection. The second picture, it measures over the "real" 2D plane glued to the front of that wing (which is easy, and doesn't even use projection. Just Vector3.angle)

The first picture, it looks maybe like the 2D plane is going straight down from the from of the fuselage (but not sure, it has to do with lift?) In that case, you project each vector onto that plane, and then measure.

But it starts with figuring out exactly which plane (does yours tilt when the plane rolls?)

avatar image NoseKills · Jan 07, 2015 at 07:12 AM 1
Share

From what i understand you should project velocity to the plane defined by airplane.up and airplane.forward vectors, and take the angle between that vector and airplane.forward.

avatar image Victory Dan Greene · Jan 07, 2015 at 03:01 PM 1
Share

@Nose$$anonymous$$ills seems right to me; in fact, for computing lift, you probably just need the dot product of the velocity and airplane.up (or wing.up if it's appreciably different).

avatar image Glurth · Jan 07, 2015 at 03:31 PM 1
Share

I like the other comments, but let me try to explain a different way. The airstream vector you are looking for can be described as “the component of the velocity vector that is pointing forward”. $$anonymous$$uch like you would say the Y of the velocity vector can be described as “the component of the velocity vector that is pointing up.” Obviously you won’t be able to just extract a single coordinate here, ins$$anonymous$$d you will want to use a dot product of your velocity vector and your forward vector. This will tell you how fast you are moving in the forward direction. The dot product computation INCLUDES the angle you are looking for and is defined as |VectorSpeed| Cos(theta), where theta is the angle between the two vectors. $$anonymous$$ultiple this scalar (a non-vector) result with your VectorForward to get the final vector your looking for. You can also use this formula and the dot product result to deter$$anonymous$$e the angle theta.
This picture in the wiki for dot product has a great picture that describes this exactly.

http://en.wikipedia.org/wiki/Dot_product#mediaviewer/File:Dot_Product.svg

avatar image gamedevpadawan · Jan 07, 2015 at 05:41 PM 1
Share

Thank you all. Should be some '+' or 'Thanks' button in comments.

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

6 People are following this question.

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

Related Questions

Calculate launch angle based on launch direction 2 Answers

How to find direction Vector for a collision surface? 1 Answer

I want to calculate angles between a series of points and find the total angle between start and finish. 2 Answers

Working out Difference in Rotation 2 Answers

2D Ball Bouncing Angle Problem (Without Rigidbody) 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